Compiling “static” binary from fortran on mac

I would like to compile the fortran code on mac so that it does not depend on any shared library. Ultimately, I want to be able to send binary files to other people and just work (assuming the processor has the correct architecture). I noticed that g95 and ifort have a -static flag that doesn't work on Mac.

If I consider the following program:

program test
  print *,'hello world'
end program test

and compile it with

ifort -static-libgcc -static-intel test.f90

The resulting binary is still dependent on several shared libraries:

valinor:tmp tom$ otool -L a.out 
a.out:
    /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 103.0.0)
    /usr/lib/libmx.A.dylib (compatibility version 1.0.0, current version 315.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 124.1.1)

So, is there a way to compile fortran code correctly so that it does not depend on any shared library on a Mac?

+3
2

Mac OS X .

. Mac OS X.

. C Darwin , libgcc .., . , .

+2

: , Mac OS X. , - : , ' Mac Apple.

PS: libgcc_s, -static-libgcc . , , ...

+1

Source: https://habr.com/ru/post/1719648/


All Articles