I have a project that produces a shared library which is linked against another, also shared, library.
When I compile and link it with gcc 4.4, everything works:
- no compile-time warning or error,
- no linking time warning or error and
ldd libmyproject.socorrectly reports the dependency with the other shared library.
When I compile and link it with gcc 4.5, on the other hand (with the exact same flags), I have the following symptoms:
- no compile-time warning or error,
- no linking time warning or error but
- the library is not correctly linked against the other shared lib: this manifest itself when I run
lddand don’t see the connection, and also when I try to use it: while it works with gcc 4.4, it crashes at run-time with gcc 4.5 with a “symbol not found” error (of course from the other lib).
I looked at the release notes and my intuition is that it has something to do with the new link-time optimization, but I could not understand them in enough details.
Did anyone encounter a similar situation and/or has any advice to offer?
(Note that results with 4.6 are in appearance identical to 4.5).
To summarize Mat’s answer from GCC 4.5 vs 4.4 linking with dependencies and the discussion in the comments, you need to link with: