是否可以在 Linux 中编译独立的 Fortran 可执行文件?
Is it possible to compile a standalone Fortran executable in Linux?
例如,假设我在一台计算机上编写了一个 Fortran 程序,并想在另一台计算机上 运行 它可能没有所需的库 and/or 有不同的编译器(或者更好,根本没有 Fortran 编译器)。是否可以创建一个包含所有依赖项的可执行文件?
我在 Fedora 26 中使用 gfortran (7.2.1),有时在我的代码中使用 LAPACK 例程。
在程序中使用 -static
选项
program main
write (*,*) 'Hello'
end
我得到输出
gfortran -static a.f90
/usr/bin/ld: cannot find -lm
/usr/bin/ld: cannot find -lm
/usr/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
gfortran -static-libgfortran a.f90
没有错误
例如,假设我在一台计算机上编写了一个 Fortran 程序,并想在另一台计算机上 运行 它可能没有所需的库 and/or 有不同的编译器(或者更好,根本没有 Fortran 编译器)。是否可以创建一个包含所有依赖项的可执行文件?
我在 Fedora 26 中使用 gfortran (7.2.1),有时在我的代码中使用 LAPACK 例程。
在程序中使用 -static
选项
program main
write (*,*) 'Hello'
end
我得到输出
gfortran -static a.f90
/usr/bin/ld: cannot find -lm
/usr/bin/ld: cannot find -lm
/usr/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
gfortran -static-libgfortran a.f90