Re: MinGW-users Digest, Vol 32, Issue 30

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Re: MinGW-users Digest, Vol 32, Issue 30

max reason
> max reason <maxreason@...> writes:
>> I have been developing a portable 3D game/graphics/simulation
>> engine for over one year now, and recently decided to switch
>> IDEs - from eclipse to CodeBlocks plus gcc/g++ on Linux, and
>> from VisualStudio2005 to CodeBlocks plus mingw on Windoze.
> Part of problem description pruned from original posting.
>> #1: 'memset' is not declared in this scope.
>> #2: many "undefined references" to functions in .s file:
>>     A: undefined reference to '_math_sin'
>>     B: undefined reference to '_math_cos'
>>     C: undefined reference to '_math_abs'
>>     D: undefined reference to '_math_sqrt'
>>     #: and dozens more similar errors
>> #1: the documentation for the memset() function says
>> #include <string.h> is necessary to declare memset().
>> Sure enough, when I look inside the <string.h> file
>> in the "c:/mingw/include/" directory I see that the
>> memset() function *is* declared.  Thus, I am confused.
>> #2: all functions mentioned in the "undefined reference"
>> errors are inside my icemathasm.s assembly-language file.
>> That file is added to my CodeBlock project, and is shown
>> inside the "ASM sources" section of the project workspace
>> in the IDE.  Furthermore, I do see that the build process
>> has created a icemathasm.o file - which presumably would
>> contain those functions.  Thus, again I am confused.
> More pruning.
>> Thanks.  Max
> Not sure if this is your problem or not, but g++ automatically
> prepends an underscore "_" to C/C++ function names under
> Windows.  This is to be compatible with other Windows compilers.  
> Nothing is prepended under Linux.  This prepending does not
> happen automatically for routines defined in assembly.
> This means that your assembly routines have to be named
> "_math_sin" in your Windows assembly source but just "math_sin"
> under Linux.
> You can write "portable" assembly for Windows/Linux under gas,
> but you may need to run your assembly source through the
> preprocessor.  (See the __USER_LABEL_PREFIX__ entry under the
> Common Predefined Macros section of the cpp info documentation.)
> I can provide more detail if this turns out to be the problem
> and you are looking for Windows/Linux portability.
> Tony Richardson

 Thanks!  I prefixed the function names in my icemathasm.s file
 with underlines, and that fixed problem as #2 described above.
 I supposed this is gross, but doesn't hurt too much, to put
 both labels in the assembly language and then not worry
 thereafter about which tools compile the code.  Yuck?

 Unfortunately, other problems remain, like the memset()
 issue described previously, and here is another problem.

 The following 2 lines:
    data = (u08*) _aligned_malloc (bytes, 16);
    if (buffer) { _aligned_free (buffer); }
 generate errors:
    undefined reference to '__aligned_malloc'
    undefined reference to '__aligned_free'

 Am I supposed to put some .a or .lib or .dll file in my
 project directory?  Or what should I know that I don't?
 Thanks.  Max

This email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:

This list observes the Etiquette found at
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) HTML/MIME encoded mail
3) Improper quoting
4) Improper trimming