ongoing link issues

Dimitry Andric dim at FreeBSD.org
Wed Dec 9 17:56:53 UTC 2015


On 09 Dec 2015, at 17:50, William A. Mahaffey III <wam at hiwaay.net> wrote:
> 
> I am still trying to statically link my inhouse code. I switched to using g++5 in the link line:
...
> g++5 -o /usr/local/bin/PreBFCGL.opteron.TEST.static -Wl,-s,--allow-multiple-definition,-rpath=/usr/local/lib/gcc5 Main.o -L/home/wam/V8/Cnx/test/junk/cart/unstaggered/bfc/pre/../lib/R4/opteron -L/home/wam/lib/R4 -L/usr/lib64/openmotif -Wl,--start-group -lmaiPre -lPre -lPrecxx -lutils -lftndmp -lftnO2pre -lftnO2 -lBC_Phi -license -Wl,--end-group -lMemIO -lMotif -lStdHash -lmpi -ltet -lgomp -lMrm -lXm -lXt -lGL -lGLU -lGLw -lX11 -ljpeg -lpng -lz -lm -static-libgcc -static-libstdc++ -Bstatic -lgfortran -static-libgfortran && \rm -f Main.o

> [wam at kabini1, ~, 10:51:48am] 917 % PreBFCGL.TEST
> /lib/libgcc_s.so.1: version GCC_4.6.0 required by /usr/local/lib/gcc48/libgfortran.so.3 not found
> [wam at kabini1, ~, 10:51:52am] 918 % PreBFCGL.TEST.static
> /lib/libgcc_s.so.1: version GCC_4.6.0 required by /usr/local/lib/gcc48/libgfortran.so.3 not found
> [wam at kabini1, ~, 10:52:02am] 919 % PreBFCGL.bdver1.TEST.static
> /lib/libgcc_s.so.1: version GCC_4.6.0 required by /usr/local/lib/gcc48/libgfortran.so.3 not found
> [wam at kabini1, ~, 10:52:04am] 920 % uname -a

Instead of all the complicated stuff above, can't you simply use -static
while linking?  I'm not sure why you want a half-dynamic, half-static
executable?

If you want to link *some* of the libraries statically, you must enclose
these in a -Wl,-Bstatic ... -Wl,-Bdynamic pair.  For example:

-Wl,-Bstatic -lstdc++ -lgfortran -lgcc -Wl,-Bdynamic

Also, you should probably link using gcc5 instead of g++5, otherwise the
latter might add its own -lstdc++ arguments.

-Dimitry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/freebsd-toolchain/attachments/20151209/c5b53943/attachment.sig>


More information about the freebsd-toolchain mailing list