Code::Blocks Forums

User forums => Help => Topic started by: roxlu on August 09, 2009, 11:01:28 pm

Title: link order?
Post by: roxlu on August 09, 2009, 11:01:28 pm
hi, I've added a static lib added to my Build Options > Linker Settings > Other linker options list, like "../../../addons/ofxOsc/libs/oscpack/lib/win32/oscpack.a". I added this at the bottom of the list which resulted in linker errors that it
couldnt fnd hton_* etc..

I solved this by moving the line the oscpack.a in the other linker options list to just above -lws2_32.
Now, I'm wondering why this solved it?

I can also solve this problem by added libws2_32.a to the Compiler settings.

roxlu
Title: Re: link order?
Post by: MortenMacFly on August 10, 2009, 07:07:22 am
Now, I'm wondering why this solved it?
Order matters when linking. If liba requires libb than you cannot link libb before liba as the linker cannot resolve the symbols.
Title: Re: link order?
Post by: mariocup on August 10, 2009, 12:55:21 pm
Hi roxlu,

the linker can also automatically resolve cyclic references so that the order of libraries be-
comes irrelevant. The corresponging linker option is

Code
-Wl,--start-group <list> -Wl,--end-group.

<list> is used here a placeholder for your list of libraries.

You have to specify this option in the other linker settings.
Title: Re: link order?
Post by: thomas on August 10, 2009, 07:44:24 pm
the linker can also automatically resolve cyclic references so that the order of libraries be-
comes irrelevant.
Don't use that unless you can't do otherwise though, as this will take about 10-15 times as long to link.