Strange linking problems

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
User avatar
turkeyman
Posts: 75
Joined: Wed Oct 20, 2004 7:38 pm
Location: Brisbane, Australia
Contact:

Strange linking problems

Post by turkeyman »

Code: Select all

Linking...
../Fuji/Lib/libFuji_Debug_PSP.a(System_PSP.o): In function `loaderInit()':
System_PSP.cpp:(.text+0x60): undefined reference to `pspSdkInstallNoDeviceCheckPatch'
collect2: ld returned 1 exit status
Can anyone tell me why i might be getting this error?

heres my command line.. (not working)
psp-gcc.exe $(IntDir)/*.o ../Fuji/Lib/libFuji_$(ConfigurationName).a -LC:\cygwin\usr\local\pspdev\psp\sdk\lib -o$(TargetName).elf -lpspkernel -lpspgu -lpspusb -lpspusbstor -lstdc++ -lm -lpspdebug -lpspdisplay -lpspge -lpspctrl -lc -lpspglue -lc -lpspuser

I am definately linking pspkernel, and the sample ap builds fine.. (using the pspsdk sampel ap makefile)

On an unrelated note (or maybe related, who knows) I'm getting some strange linking problems related to the order i specify libs on the command line..

I noticed this a while back, and i couldnt figure out any logic to it.. So when i had link errors, i just rearranged the order of my -l's on the command line until it links without errors...

This is just weird... Can anyone enlighten me about this weird link order logic that GCC seems to have issues with?
rinco
Posts: 255
Joined: Fri Jan 21, 2005 2:12 pm
Location: Canberra, Australia

Post by rinco »

i read somewhere that libs cannot depend on libs that precede them.

and once in a while there'll be a need to refer to something twice (probably a cyclic dependency), eg: -lc -lpspglue -lc

but in your case, you have missed -lpspsdk (pspSdk* functions).
User avatar
turkeyman
Posts: 75
Joined: Wed Oct 20, 2004 7:38 pm
Location: Brisbane, Australia
Contact:

Post by turkeyman »

oh oops!! :P
i did too..
thanks for that! :)

sometimes these silly little things just slip by and you need a fresh pair of eyes to pick it :P

interesting with the -lc -lpspglue -lc thing.. i noticed that, and i was wondering what that was about..
i assume that GCC is intelligent enough to not double link libs then? :/

in VC if you link a lib twice, it will give a multiple definitions error..

thanks dude
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

The circular dependency is a mistake I introduced, which I will be fixing shortly. The -lpspglue will also disappear so it will end up being just -lc. However, libc will still depend on -lpspuser.
ooPo
Site Admin
Posts: 2023
Joined: Sat Jan 17, 2004 9:56 am
Location: Canada
Contact:

Post by ooPo »

The order of linking is such that as it links in each library it will only link in the parts/functions that are required by previously specified libs. This is why you may need to specify a library more than once when two libs depend on each other.

There is a commandline option to just link in everything possible and you can later use psp-strip out the parts you don't need, but that isn't as nice. :)
User avatar
turkeyman
Posts: 75
Joined: Wed Oct 20, 2004 7:38 pm
Location: Brisbane, Australia
Contact:

Post by turkeyman »

cool, thats interesting to know
thanks :)
Post Reply