gfortran -static on MACs
Janus Weil
janus@gcc.gnu.org
Tue Feb 13 19:55:00 GMT 2018
Dear Sewell,
>> Bottom line is I simple want to create an executable from my Fortran program that people on other MAC OSX
>> systems can run without having gfortran installed. If that is really impossible
I don't think it's impossible. That is basically what
-static-libgfortran is for, which in principle seems to work for you.
Problem is, it's not complete in a sense: It links your program to the
static version of libgfortran, but still uses a dynamic libquadmath.
I think the cleanest solution to this problem is to add a
-static-libquadmath flag to gfortran, as proposed in PR 46539. Maybe
we can get FX to dust off his old patch for this PR and make it fit
for GCC 9?
(Btw, a quick fix for you might be to simply distribute libquadmath.so
together with your application.)
Cheers,
Janus
>> Sent: Monday, February 12, 2018 1:12 PM
>> To: Manfred Schwarb
>> Cc: Sewell, Granville; fortran@gcc.gnu.org
>> Subject: Re: gfortran -static on MACs
>>
>>> 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.
>>
>> Statically linked executables are not supported on Mac OS, see:
>> https://developer.apple.com/library/content/qa/qa1118/_index.html
>>
>>
>>
>>>> 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
>>
>>
>> A -static-libquadmath flag has been proposed in the past, but
>> apparently the patch has never been committed:
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46539
>>
>> Would certainly be good to have this.
>>
>> Cheers,
>> Janus
>>
>
More information about the Fortran
mailing list