custom built gcc 4.6.0 on ubuntu 11.04 links wrong libstdc++
Asked Answered
A

2

3

my custom built gcc 4.6.0, installed in my home directory, on ubuntu 10.04, links the system libstdc++ instead of the custom built one, most of the time (as evidenced by ldd). to be more puzzling, using this newly built gcc, custom compiled openmpi libraries are linked correctly, and this is the only software i have compiled that behaves ok. does anybody have any explanation for this, or a workaround?

thanks

Anett answered 19/4, 2011 at 15:21 Comment(3)
Hmm.. Should check my gcc. I think the issue was in configuring a gcc, and can be checked in specs. To fix, you need change a rpath en.wikipedia.org/wiki/Rpath_(linking) . There must be gcc option (in machine specs too) to set a default rpath. Can you post configure options of gcc you used?Magellan
See the libstdc++ FAQ How do I insure that the dynamically linked library will be found? and Finding Dynamic or Shared Libraries in the manual.Postmark
possible duplicate of Linking g++ 4.8 to libstdc++Chuchuah
C
2

Isn't there an option to statically link the libstdc into the gcc when you configure it? --disable-shared if I understand how it works correctly. Worst case make another compile of gcc with that switch and see if you run into the issue.

Carrion answered 15/6, 2011 at 4:25 Comment(0)
H
0

I don't know why this isn't detailed more clearly on the GCC website for end-users. The GCC FAQ clearly states this is a common problem wrt libstdc++. Environment variables are troublesome. Wrapping the linker, nobody knows how to do that. Editing /etc/ld.so.conf isn't an option. Adding -Wl,-rpath everywhere, come on. The easiest solution is the specs file. For a typical 64-bit x86 Linux system, go into your custom gcc installation, in dirname `g++ -print-libgcc-file-name`and then run g++ -dumpspecs > specs. Edit that file, find the *link_command: section. After %(link_libgcc) add -rpath /home/user/bin/gcc-9/lib64 (of course use your own path). Or add the same rpath to end of *link: section. Alternatively, configure gcc with --with-specs='%{!static:%x{-rpath=/home/user/bin/gcc9/lib64} %x{-enable-new-dtags}}' . Enjoy your own C++ compiler that generates binaries that just work.

See also:

Hephzipah answered 25/4, 2019 at 15:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.