#13259 - MumblyJoe - Wed Dec 10, 2003 2:10 am
OK, I am trying to link in some music to a game I am writing, but I am having trouble.
I have a:
.cpp file that has a long array of data - the music.
.h file that has an extern declaration of that array.
.cpp file which is the game and includes the above .h file.
I compiled the .cpp file with the music in it using g++, no errors.
I compile the game with g++ .cpp file, no errors.
I link the two together with g++, and the array cannot be found.
I have tried using extern "C" for both to stop name mangling, and the nm tool which comes with devkitadv says that 'heyladies' (my array name) is the name in the music .o file, and says that my game .o file has an extern variable of the same name, but somehow the linker is freaking out and not doing what I want.
My .bat file for compiling the music is this:
My .bat file for compiling my game and linking the two is this:
I have tried re-ordering the files in the linking line, that didnt help either. Oh and I know .bat files are a nasty way of doing things and I should use makefiles but I like this way.
Just including the array of music into my game instead of compiling it seperately and linking them is out of the question, as it is the whole of Hey Ladies by The Beastie Boys, and the music file takes over 30 minutes to compile on the piece of shit computer I use for GBA development, while compiling it seperately once (and sleeping while it does it) then compiling the game and linking them takes like 15 seconds each time i make a change.
Heres the error I get:
Any ideas folks?
_________________
www.hungrydeveloper.com
Version 2.0 now up - guaranteed at least 100% more pleasing!
I have a:
.cpp file that has a long array of data - the music.
.h file that has an extern declaration of that array.
.cpp file which is the game and includes the above .h file.
I compiled the .cpp file with the music in it using g++, no errors.
I compile the game with g++ .cpp file, no errors.
I link the two together with g++, and the array cannot be found.
I have tried using extern "C" for both to stop name mangling, and the nm tool which comes with devkitadv says that 'heyladies' (my array name) is the name in the music .o file, and says that my game .o file has an extern variable of the same name, but somehow the linker is freaking out and not doing what I want.
My .bat file for compiling the music is this:
Code: |
g++ -c -nostartfiles -mthumb -mthumb-interwork -fno-rtti -fno-exceptions -o heyladies.o heyladies.c |
My .bat file for compiling my game and linking the two is this:
Code: |
g++ -c -O3 -mthumb -mthumb-interwork -fno-rtti -fno-exceptions -o Frogger.o Frogger.cpp
g++ -mthumb -mthumb-interwork -o Frogger.elf heyladies.o Frogger.o objcopy -O binary Frogger.elf Frogger.gba |
I have tried re-ordering the files in the linking line, that didnt help either. Oh and I know .bat files are a nasty way of doing things and I should use makefiles but I like this way.
Just including the array of music into my game instead of compiling it seperately and linking them is out of the question, as it is the whole of Hey Ladies by The Beastie Boys, and the music file takes over 30 minutes to compile on the piece of shit computer I use for GBA development, while compiling it seperately once (and sleeping while it does it) then compiling the game and linking them takes like 15 seconds each time i make a change.
Heres the error I get:
Code: |
C:\Programming\GBA Projects\TileFrogger>g++ -c -O3 -mthumb -mthumb-interwork -fno-rtti -fno-exceptions -o Frogger.o Frogger.cpp
C:\Programming\GBA Projects\TileFrogger>g++ -mthumb -mthumb-interwork -o Frogger.elf heyladies.o Frogger.o Frogger.o: In function `Frogger::Start()': Frogger.o(.gnu.linkonce.t._ZN7Frogger5StartEv+0xe4): undefined reference to `heyladies' collect2: ld returned 1 exit status C:\Programming\GBA Projects\TileFrogger>objcopy -O binary Frogger.elf Frogger.gba objcopy: Frogger.elf: No such file or directory Tool completed with exit code 1 |
Any ideas folks?
_________________
www.hungrydeveloper.com
Version 2.0 now up - guaranteed at least 100% more pleasing!