gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > Linking to a library

#28087 - mr_square - Tue Oct 26, 2004 9:12 pm

I'm using devkitadvance, and want the compiler to link to a library in a subfolder - how do I do this?

at the moment I have a make.bat file with the following in it:

Code:

path=C:\devkitadv\bin

g++ -o main.elf city.o citybackdrop.o defines.cpp main.cpp testroom.cpp room.cpp ball.cpp collisionDetector.cpp DMA.cpp fallState.cpp drawState.cpp background.cpp idleState.cpp jumpState.cpp lookUpState.cpp swipeState.cpp runLeftState.cpp trig.cpp kneelState.cpp runRightState.cpp playerState.cpp -lm

objcopy -O binary main.elf main.bin

#28090 - isildur - Tue Oct 26, 2004 9:29 pm

Here is a good link with all the gnu compiler's options and parameters

http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_2.html#SEC2


Check under the options for linking.

#28096 - mr_square - Tue Oct 26, 2004 9:50 pm

thanks. I'm now doing:

Code:

path=C:\devkitadv\bin

g++ -o -LLibAAS -ILibAAS -lAAS main.elf city.o citybackdrop.o defines.cpp main.cpp testroom.cpp room.cpp ball.cpp collisionDetector.cpp DMA.cpp fallState.cpp drawState.cpp background.cpp idleState.cpp jumpState.cpp lookUpState.cpp swipeState.cpp runLeftState.cpp trig.cpp kneelState.cpp runRightState.cpp playerState.cpp -lm

objcopy -O binary main.elf main.bin


But it now complains that main.elf doesn't exist :( Before it was compiling all the files into main.elf, and then converting that to a .bin, but now it seems to think its part of the source code...

(I'm trying to link to the AAS.a library in the LibAAS subfolder)

#28105 - sajiimori - Tue Oct 26, 2004 10:46 pm

Put the output file name right after -o.

#28127 - tepples - Wed Oct 27, 2004 2:00 am

Think of some of the dash options (such as -o) as like prepositions in English. The object (in this case a filename) must immediately follow the preposition.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.