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:
ldd libmyproject.so
correctly 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:
ldd
and 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).
GCC uses a separate linker program (called ld.exe ) to perform the linking.
GCC 11 adds support for non-rectangular loop nests in OpenMP constructs and the allocator routines of OpenMP 5.0, including initial allocate clause support in C/C++. The OMP_TARGET_OFFLOAD environment variable and the active-levels routines are now supported.
The GNU Compiler Collection (gcc) The GNU Compiler Collection, gcc, can compile programs written in C, C++, Java and several other languages. It provides many useful command line options and syntax extensions, and also serves as a powerful frontend for the GNU linker, ld.
Status of Experimental C++11 Support in GCC 4.8GCC provides experimental support for the 2011 ISO C++ standard. This support can be enabled with the -std=c++11 or -std=gnu++11 compiler options; the former disables GNU extensions.
This tell gcc to compile the file using the compiler options shown (and those generated from the call to pkg-config, then call the linker With linker options ,--export-dynamic. Add -v for verbose output, e.g. gcc -v ..... and you will see all that is put together to compile and link.
Support for a number of older systems and recently unmaintained or untested target ports of GCC has been declared obsolete in GCC 4.5. Unless there is activity to revive them, the next release of GCC will have their sources permanently removed. Details for the IRIX, Solaris 7, and Tru64 UNIX obsoletions can be found in the announcement.
Unless there is activity to revive them, the next release of GCC will have their sources permanently removed. Solaris 9 (*-*-solaris2.9). Details can be found in the announcement.
The function attribute noinline no longer prevents GCC from cloning the function. A new attribute noclone has been introduced for this purpose. Cloning a function means that it is duplicated and the new copy is specialized for certain contexts (for example when a parameter is a known constant).
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:
--copy-dt-needed-entries and --no-as-needed
You can debug your dynamically linked application with LD_DEBUG environment variable. This is an option of ld-linux.so.2
; ldd is a script to set such option too. All options are described at http://linux.die.net/man/8/ld-linux man page.
How to use LD_DEBUG (in bash; the easiest way):
$ LD_DEBUG=all ./your_program
This will turn on debugging of ld-linux.so.2 - the run-time dynamic linker. It will print a lot of debugging to stdout or stderr and you will be able to
LD_DEBUG=all ./your_program_4.4
" and "LD_DEBUG=all ./your_program_4.5
"Also, you should give us more information:
uname -a
) What is the version of libc? (run in bash for a in /lib*/libc.so.*;do echo $a; $a; done
)UPDATE: Good and exact answer is here: GCC 4.5 vs 4.4 linking with dependencies (by Mat)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With