Correct way to statically link in gfortran libraries on OSX -


i've fortran program i'd distribute, i'd statically link in gfortran libraries.

if compile program following flags:

gfortran -o myprog -static-libgfortran -static-libgcc  myprog.f 

otool tells me it's statically linked in of gofrtran libraries, not libquadmath:

otool -l myprog  /usr/local/gfortran/lib/libquadmath.0.dylib (compatibility version 1.0.0, current v         /usr/lib/libsystem.b.dylib (compatibility version 1.0.0, current version 159.1.0) 

there static libquadmath library /usr/local/gfortran/lib/libquadmath.a, every link line tried either ended full static link (which isn't supported on osx) or dynamic link libquadmath.

i've managed create want removing libquadmath.0.dylib , libquadmath.dylib /usr/local/gfortran/lib/, , linker pulls in static library.

however, seems clunky least.

can suggest more elegant way of doing this?

thanks!

i know old tracker, maybe still interested in solution works.

let's have code:

! fort_sample.f90 program main   write (*,*) 'hello'   stop end 

first, compile stuff:

gfortran -c -o fort_sample.o fort_sample.f90 

then, link stuff

ld -o ./fort_sample -no_compact_unwind \ -arch x86_64 -macosx_version_min 10.12.0 \ -lsystem \ /usr/local/gfortran/lib/libgfortran.a \ /usr/local/gfortran/lib/libquadmath.a \ /usr/local/gfortran/lib/gcc/x86_64-apple-darwin16/6.3.0/libgcc.a \ fort_sample.o 

you can execute it

./fort_sample  hello 

you can notice quadmath no longer there

> otool -l fort_sample fort_sample:     /usr/lib/libsystem.b.dylib (compatibility version 1.0.0, current version 1238.51.1) 

i guess looking in first place. no removing dylibs, no symbolic links, etc.


Comments