News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

link order?

Started by roxlu, August 09, 2009, 11:01:28 PM

Previous topic - Next topic

roxlu

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

MortenMacFly

Quote from: roxlu on August 09, 2009, 11:01:28 PM
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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

mariocup

Hi roxlu,

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


-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.

thomas

Quote from: mariocup on August 10, 2009, 12:55:21 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.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."