我在windows7上使用cygwin (x86_64)的gfortran来编译一些来自NASA的旧fortran代码。当我使用
gfortran cma.f -o cma.exe代码可以编译并运行,但需要在同一文件夹中使用以下四个库: cyggcc_s-seh-1.dll、cyggfortran-3.dll、cygquadmath 0.dll和cygwin1.dll
我想让它独立运行,所以我试过了
gfortran cma.f -static -o cma.exe但是随后我得到了几个"relocation truncated to fit: R_X86_64_PC32 to undefined symbol“错误:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.3/libgfortran.a(write.o): In function `write_float':
/usr/src/debug/gcc-4.9.3-1/libgfortran/io/write_float.def:1300:(.text$write_float+0x15c): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `quadmath_snprintf'
/usr/lib/gcc/x86_64-pc-cygwin/4.9.3/libgfortran.a(write.o): In function `determine_en_precision':
/usr/src/debug/gcc-4.9.3-1/libgfortran/io/write_float.def:1213:(.text$write_float+0x7cf): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `quadmath_snprintf'
/usr/lib/gcc/x86_64-pc-cygwin/4.9.3/libgfortran.a(write.o): In function `write_float':
/usr/src/debug/gcc-4.9.3-1/libgfortran/io/write_float.def:1300:(.text$write_float+0x84e): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `quadmath_snprintf'
/usr/lib/gcc/x86_64-pc-cygwin/4.9.3/libgfortran.a(write.o): In function `output_float_FMT_G_16':
/usr/src/debug/gcc-4.9.3-1/libgfortran/io/write_float.def:1140:(.text$write_float+0xf22): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `quadmath_snprintf'
/usr/src/debug/gcc-4.9.3-1/libgfortran/io/write_float.def:1140:(.text$write_float+0x1781): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `quadmath_snprintf'
/usr/lib/gcc/x86_64-pc-cygwin/4.9.3/libgfortran.a(read.o): In function `_gfortrani_convert_real':
/usr/src/debug/gcc-4.9.3-1/libgfortran/io/read.c:175:(.text$_gfortrani_convert_real+0x72): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `strtoflt128'
/usr/lib/gcc/x86_64-pc-cygwin/4.9.3/libgfortran.a(read.o): In function `_gfortrani_convert_infnan':
/usr/src/debug/gcc-4.9.3-1/libgfortran/io/read.c:251:(.text$_gfortrani_convert_infnan+0x53): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `strtoflt128'
collect2: error: ld returned 1 exit status我刚开始从源代码进行编译,但我已经做过一些编程(主要是在matlab/octave中)。我不知道Fortran,代码有4418行,做一些复杂的热力学。因此,修改代码对我来说不是一个很好的选择。
我还知道它可以使用Intel Fortran composer XE2013,更新5,编译器在MS Visual Studio的32位windows控制台应用程序中编译,具有以下选项: 132列,32位发布版本,并且没有运行时数组边界检查。但我没有英特尔编译器。
因此,这应该只是gfortran使用哪个编译器选项的问题。我已经尝试了很多不同的标志,但到目前为止还没有一个成功。那么如何才能让exe独立运行呢?
还有一些类似的问题,但是这些解决方案似乎涉及到代码是如何编写的。我不能更改代码,所以我需要一个涉及如何编译代码的解决方案。
发布于 2015-08-23 21:02:46
我认为你必须去掉cygwin64中的"-static“。cygwin64包中只提供了gfortran的共享库版本。
https://stackoverflow.com/questions/31706089
复制相似问题