On Wed, Jul 15, 2009 at 10:41 PM, Ian Lance Taylor<iant@xxxxxxxxxx> wrote: > Zachary Turner <divisortheory@xxxxxxxxx> writes: > >> The codebase is large, but is new to linux. It was originally >> developed on windows and then ported to linux. It makes heavy use of >> C++, STL, and boost and we'd like to (if possible) link *everything* >> statically. This means libc, libgcc, libstdc++, boost, libpthread, >> etc. > > This message is not appropriate for the gcc@xxxxxxxxxxx mailing list. > It would be appropriate for the gcc-help@xxxxxxxxxxx mailing list. > Please take any followups to gcc-help. Thanks. > > This is actually not a gcc issue. This is a library issue. On > GNU/Linux, the library is glibc. The glibc maintainers have decided > that they do not want to support static linking (I personally disagree > with this position). They only support dynamically linking against > libc. Static linking sort of grudgingly works, but some things will > fail. For example, if your statically linked program does DNS lookups, > it will generally fail on any system which is not running the precise > version of glibc as the system on which it was built. > > My guess is that the problems you are encountering are problems > statically linking with glibc. You can certainly bring these up with > the glibc maintainers--see http://sourceware.org/glibc . However, they > will ignore you with prejudice. > > You may want to consider using -Bstatic and -Bdynamic to statically link > everything except glibc. > > Ian > Thanks for your response despite the fact that I apparently posted to the wrong list. However, one thing still bothers me. In particular that an out-of-the-box installation of gcc appears to produce bogus executables on gnu linux and neither the documentation, the compiler, nor the linker issue any kind of warnings stating that this might happen (or has already happened). In other words, the -static linker option, at least under its current implementation, appears to be *incompatible* with g++ (and for that matter, gcc as well) on gnu linux. The documentation does state that the -static option behaves differently depending on whether or not it's supported by the platform. It seems to be unsupported on this platform, so shouldn't it simply either report an error that this option is unavailable, or produce an executable that is "as static as possible" but at least works? For example, > g++ -v -static test.cpp -o test produces an unusable executable. g++ -v test.cpp -o test -nodefaultlibs -Wl,-Bstatic -lstdc++ -lm -lgcc -lgcc_eh -Wl,-Bdynamic -lc seems to work correctly (I haven't tested it in our large codebase yet, just a simple program that throws and catches an exception in main). Since the first command line can apparently *never* produce correct results, could it be changed to have the same behavior as the second command line on gnu-linux?