Zachary Turner <divisortheory@xxxxxxxxx> writes: > 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? When I try -static with g++ on a hello, world program on GNU/Linux, the resulting program does work, in that it prints hello, world. I haven't tried running valgrind on it. If you find that -static gives you a completely unusable executable--one that doesn't work at all--then something may be wrong. I tried gcc 4.3.2 on Fedora Core 10 using glibc 2.9.3. Given that -static does work with simple executables, and given that the gcc driver does hardly anything with -static other than pass it to the linker, I think that gcc is behaving reasonably. It would be annoying for it to give an error. Ian