http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46539
Tobias Burnus <burnus at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |burnus at gcc dot gnu.org --- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-03-22 17:31:41 UTC --- (In reply to comment #2) > I hit this problem. For the application I am dealing with, I need to link > statically the compiler provided libraries while linking dynamically the > system > ones (pthread, mpi, etc.). > > Linking with "gfortran -static-libgfortran -static-libgcc -Wl,-Bstatic > -lstdc++ > -Wl,-Bdynamic" solves the problem except for "libquadmath.so.0". Work arounds: You could try to link with "gcc" rather than with gfortran, but you then need to explicitly include the gfortran, quadmath and m(ath) library: gcc -static-libgcc -Wl,-Bstatic -lstdc++ -lgfortran -lquadmath -Wl,-Bdynamic -lm as that avoids "gfortran"'s special treatment of libquadmath. [You might consider to add -Wl,--as-needed ... -Wl,--no-as-needed. That avoids linking files when they are not needed.] An alternative is to modify libgfortran.spec - and add there the "-Bstatic" ... "-Bdynamic" unconditionally. Or you create your own .spec file and load it via -specs=<filename> (The "libgfortran.spec" file is a text file in the installed GCC tree; e.g. it could be <prefix>/lib*/libgfortran.spec. If you use GCC/gfortran with "-v" the output should inform you about which file has been read - and how the linker is called.)