Author Topic: link order?  (Read 4612 times)

Offline roxlu

  • Multiple posting newcomer
  • *
  • Posts: 35
link order?
« 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

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: link order?
« Reply #1 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

mariocup

  • Guest
Re: link order?
« Reply #2 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.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: link order?
« Reply #3 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.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."