Bug 398355 - Impossible to link static libraries with circular dependencies.
Summary: Impossible to link static libraries with circular dependencies.
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-build-managed (show other bugs)
Version: 8.1.1   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: John Dallaway CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-17 02:35 EST by Thomas Martitz CLA
Modified: 2023-11-16 11:59 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Martitz CLA 2013-01-17 02:35:58 EST
In a project we have multiple static libraries (build using cdt), two of which have circular dependencies to each other, that link together into an executable (also built using cdt).

With the "GCC C Linker" selected it's impossible to build that file. The linker complains about missing references when the static libraries are simply added in the "C/(C++ Build -> Settings -> GCC C Linker -> Libraries" tab, because references of the library that appears last on the generated command line has undefined references.

The solution would be to add "--start-group -lX -lY --end-group" to the linker command line *after the list of the object files*. But that's simply not possible. The additional linker options (both the "Linker flags" and "Other options (-Xlinker [option])" fields) that can be specified on the "GCC C Linker -> Miscellaneous" tab are added to the command line before the object, which has essentially no effect.

N.B. In our project I have installed a (dirty) workaround: I have added the linker options (-Wl,--start-group,-lX,-lY,--end-group) to the "Other objects" field (and added a dummy make rule in makefile.init so make won't complain about it) to force CDT to put it after the list of objects. It works but is really ugly.
Comment 1 Dima Brigalda CLA 2020-09-09 11:48:08 EDT
Hello, I am wondering if this issue was addressed.
Comment 2 John Dallaway CLA 2023-11-16 11:59:17 EST
Resolved via: https://github.com/eclipse-cdt/cdt/issues/608