From: Tony R. <ric...@ev...> - 2009-01-30 15:57:24
|
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 |