windows-7 - "Relocation truncated to fit"仅适用于 -static

标签 windows-7 fortran cygwin gfortran

我在 Windows 7 上使用 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

但随后我收到几个“重定位被截断以适合:R_X86_64_PC32 反对 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 行长,并且做了一些复杂的热力学。所以修改代码对我来说不是一个很好的选择。

我还知道它可以在 MS Visual Studio 中使用 Intel Fortran Composer XE2013、更新 5、具有以下选项的编译器在 32 位 Windows 控制台应用程序中进行编译:132 列、32 位发行版本和无运行时数组边界检查。但我没有英特尔编译器。

所以这应该只是 gfortran 使用什么编译器选项的问题。我已经尝试了很多不同的标志,但到目前为止还没有一个成功。那么如何才能让exe独立运行呢?

还有一些类似的问题,但是这些解决方案似乎涉及代码的编写方式。我无法更改代码,因此我需要一个涉及如何编译代码的解决方案。

最佳答案

我认为你必须在 cygwin64 中删除“-static”。 AFAIK,cygwin64 软件包中仅提供了 gfortran 的共享库版本。

关于windows-7 - "Relocation truncated to fit"仅适用于 -static,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31706089/

相关文章:

windows-7 - 使用 SinkWriter 编码视频时更改 h.264 质量

c# - 在win7资源管理器中添加一个新列?

java - 安卓调试 keystore

fortran - 矩阵上的函数是应用于整个矩阵还是 Fortran 中的每一行?

c++ - 在 Visual Studio 2010 中调试由 C++ 程序调用的 Fortran dll

fortran - Fortran中READ的含义

php - 是否可以通过 cygwin 运行 php exec?

windows-7 - 有没有一种方法可以在不使用 PowerShell 或 CIM Studio 的情况下查询 WMI?

eclipse - Eclipse在Windows上的Hadoop

Windows 7 上的 Cygwin Control+D 不给出 EOF 信号