Author Topic: Linking with circulate dependencies in libraries  (Read 3449 times)

Offline johu

  • Single posting newcomer
  • *
  • Posts: 8
Linking with circulate dependencies in libraries
« on: September 01, 2009, 07:20:10 pm »
I have the problem to link when needed libraries have circulate dependencies. The normal solution is to put all libraries twice in to the command line but it seems that C::B deletes duplicate entries in the library list (<Add library> entries in the cbp file).
Thanks for any hint.
j.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Linking with circulate dependencies in libraries
« Reply #1 on: September 01, 2009, 07:37:41 pm »
Quote from: ld's man-page
--start-group archives --end-group
The archives should be a list of archive files.  They may be either explicit file names, or -l options.

The specified archives are searched repeatedly until no new undefined references are created.  Normally, an archive is searched only once in the order that it is specified on the command line.  If a symbol in that archive is needed to resolve an undefined symbol referred to by an object in an archive that appears later on the command line, the linker would not be able to resolve that reference.  By grouping the archives, they all be searched repeatedly until all possible references are resolved.

Using this option has a significant performance cost.  It is best to use it only when there are unavoidable circular references between two or more archives.

Putting
Code
-Wl,--start-group <archives> -Wl,--end-group.

into the other linker options of your project/target should do the trick.

Offline johu

  • Single posting newcomer
  • *
  • Posts: 8
Re: Linking with circulate dependencies in libraries
« Reply #2 on: September 02, 2009, 08:57:18 am »
I have about 50-100 projects in a C::B workspace which all have a library as a target and I have to link it all together in an executable project ... :-(
Regards
j.

Additionally there is the question how your trick should work. Configuring linking I see two lists, the libraries list and the linker options list. But the linker options are preceding the libraries list in the command line. For the trick I need appending. In the libraries list itself the trick does not work. Can I configure the linking command in a similar way as I can configure the build command for a certain project files via it's properties (where I can configure precompilation steps very well)?
Regards
j.
« Last Edit: September 03, 2009, 08:41:27 am by johu »

Offline johu

  • Single posting newcomer
  • *
  • Posts: 8
Re: Linking with circulate dependencies in libraries
« Reply #3 on: September 21, 2009, 05:38:55 pm »
The answer is quite easy:
In Settings/Compiler & Debugger/Other settings/Advanced options it is possible to modify the link command from
$linker $libdirs -o $exe_output $link_objects $link_resobjects $link_options $libs
to
$linker $libdirs -o $exe_output $link_objects $link_resobjects $link_options $libs $libs
This works fine for my projects.