gfortran -static on MACs
Manfred Schwarb
manfred99@gmx.ch
Sat Feb 10 19:45:00 GMT 2018
Am 10.02.2018 um 14:40 schrieb Sewell, Granville:
>
> The Linux and Windows versions of Gfortran work with
>
> gfortran -static -o prog.exe prog.f
>
> to produce an executable that can be run on other systems where gfortran is not installed.
>
> But the -static option does not seem to work with gfortran on a MAC, I get
> ld: library not found for -lcrt0.o
> and another person with a different version of gfortran on his MAC gets the same results.
>
> gfortran -static-libgfortran prog.f
>
> works, but the executable does not even seem to run on other systems with a different version of gfortran.
>
probably the following patch will help somewhat. You have to patch all files named
"libgfortran.spec" in the path of your _installed_ compiler. With this change
"-static-libgfortran" will imply static linking to libquadmath.
--- libgfortran.spec.old 2017-05-29 21:46:01.036867084 +0000
+++ libgfortran.spec 2017-08-08 12:04:01.500558409 +0000
@@ -5,4 +5,4 @@
#
%rename lib liborig
-*lib: %{static-libgfortran:--as-needed} -lquadmath %{static-libgfortran:--no-as-needed} -lm %(libgcc) %(liborig)
+*lib: %{static-libgfortran:-Bstatic} -lquadmath %{static-libgfortran:-Bdynamic} -lm %(libgcc) %(liborig)
HTH,
Manfred
> So it seems to be impossible to produce any executable with gfortran on a MAC that has the dynamic libraries loaded
> so it can run elsewhere.
>
> Is there a way to get -static to work on MACs, or any other way to produce a portable executable?
>
> Thanks for your help
>
> Granville Sewell
>
More information about the Fortran
mailing list