First I want to say that the following problem is quite possibly not a problem (or misunderstanding) in/with codeblocks. But I'm not certain, so there's a risk I am posting a question here that is a problem with the mingw64 toolset (or about my own oversight or stupidity with either package). So, please ignore this message if you're clear this is not a codeblocks issue. I posted this question at the mingw64 forum on sourceforge first, but that forum has very little traffic.
Note that I fresh installed the latest nightly build of codeblocks (and mingw64/wxwidgets packages) just yesterday, so everything is up-to-date. Even the windoze 7 system is a fresh install on a new disk drive from only a week or two ago.
I have been developing a portable 3D engine for some time. Until recently I was developing with codeblocks on 64-bit ubuntu 12.04 on one computer, and with visual studio2005 pro on 64-bit windoze xp on another computer (no dual boot). My winxp64 drive crashed and burned, so I bought a new drive and installed windoze 7. Not surprisingly, they made sure vs2005 doesn't work properly on win7, so I decided it was time to do what I should have done long ago (get out from beneath their evil thumb), and develop the windoze version with codeblocks too.
So I removed vs2005pro and installed mingw64, wxwidgets and codeblocks on my windoze 7 computer, and am now trying to run the windoze versions of one of my smaller applications in codeblocks (before trying to make my 3D engine work, which has many more dependencies). The takeaway from the above is... the code was working previously, and the linux targets are still working.
This application has the following 8 targets:
linux32_debug
linux32_release
linux64_debug
linux64_release
windoze32_debug
windoze32_release
windoze64_debug
windoze64_release
All of the linux targets build and execute properly on my 64-bit ubuntu 12.04 system.
I went through and tried to make sure all the codeblocks settings and project settings were correct, but I'm having the following problem and I don't understand what to try next. Here are the basic facts.
#1: The .h and .cpp files are identical for both projects, with #ifdef LINUX and #ifdef WINDOZE where necessary.
#2: I can build and execute the windoze64_debug target, but trying to build the windoze32_debug target generates <undefined reference to 'math_sin'> errors (and a number of other symbols too, all of which are in an assembly-language file called <icemathasm32.s>.
#3: The only difference in project files is the following. The <icemathasm32.s> file is part of the linux32_xxxx and windoze32_xxxxx targets, and the <icemathasm64.s> file is part of the linux64_xxxx and windoze64_xxxx targets. This is necessary because 32-bit and 64-bit assembly language is different. Both files are identical in the sense they have the same function-name symbols and such, but the assembly-language code for each function is different. This works fine when building all 4 linux targets with codeblocks on the 64-bit ubuntu 12.04 system.
#4: I have checked many, many times, and the compiler and linker are both getting an -m32 option for the windoze32_xxxxx targets, and an -m64 option for the windoze64_xxxxx targets.
#5: I have looked inside the assembly-language files repeatedly, verified they look fine, and all the function symbols that are producing "undefined reference" errors are declared in .globl lines as appropriate. Furthermore, the exact same assembly-language files built and execute correctly on my linux system.
#6: I have performed "build => clean" many times, and verified the .o files are gone, then performed "build => build" again and noted all the appropriate .o files are created, including <icemathasm32.o> in the windoze32_xxxxx target directories and <icemathasm64.o> in the windoze64_xxxxx target directories.
#7: The size of the <icemathasm32.o> file produced on 64-bit ubuntu 12.04 is 6408 bytes, while the size of the <icemathasm32.o> file produced on 64-bit windoze 7 is 6231 bytes. I'm not sure why they are different sizes, but that small difference does not worry me. Maybe it should?
#8: In an attempt to narrow down the problem, I moved the <icemathasm32.o> file from the linux32_debug directory into the windoze32_debug directory, and tried to build. This produces the same "undefined reference" errors.
#9: The following is the final build line for windoze64_debug (displayed in build-log tab in codeblocks):
g++.exe -o windoze64_debug\bin\ice.exe windoze64_debug\icenoise.o windoze64_debug\iceoptics.o windoze64_debug\iceparse.o windoze64_debug\icetext.o windoze64_debug\icetime.o windoze64_debug\icetimer.o windoze64_debug\icefile.o windoze64_debug\ice.o windoze64_debug\icemath.o windoze64_debug\iceapp.o windoze64_debug\icemathasm64.o windoze64_debug\icememory.o -m64
#10: The following is the final build line for windoze32_debug (displayed in build-log by codeblocks):
g++.exe -o windoze32_debug\bin\ice.exe windoze32_debug\icenoise.o windoze32_debug\iceoptics.o windoze32_debug\iceparse.o windoze32_debug\icetext.o windoze32_debug\icetime.o windoze32_debug\icetimer.o windoze32_debug\icefile.o windoze32_debug\ice.o windoze32_debug\icemath.o windoze32_debug\iceapp.o windoze32_debug\icemathasm32.o windoze32_debug\icememory.o -m32
I am lost. I'll bet there is some silly setting somewhere or other that will make me look stupid when we figure this out, but I've looked through the settings and haven't noticed anything obvious. Except probably in retrospect when someone points it out to me.
What am I missing? Is it possible that the mingw64 assembler doesn't make the .globl symbols visible only when assembling 32-bit assembly language? I'm not sure what else could be happening, but that seems too fundamental to be possible (too many people would be having this problem).
What am I doing wrong?
PS: I just executed "nm icemathasm32.o" in both windoze32_debug and linux32_debug directories, and the output was identical. The symbols that are generating "undefined reference" all have a capital T next to their names (I assume indicating they are global symbols in the text section).
PS: I just realized the problem might somehow be related to decoration on the symbol names? Does that make any sense? The output of nm shows the names without any leading decoration (not even an underline character), and no decoration following the name either. When I do this to other .o files (generated from my .cpp files), they all have a leading underline and no suffix decoration. Hmmmm. Why does this not happen on linux and not happen on windoze in the 64-bits variant (where the symbols have no decoration whatsoever in both the assembly language file or my other cpp files). Do I need some kind of _cdecl or something when I declare functions in windoze, or something?