我在64位Windows上使用mingw,试图编译一个fortran程序。链接到库时,它返回错误:E:/Users/Malcolm/netcdf-4.1.3-antho/lib\libnetcdf.a: member E:/Users/Malcolm/netcdf-4.1.3-antho/lib\libnetcdf.a(libnetcdf_la-stub.o) in archive is not an object
当我在存档文件上使用nm
时,它说无法识别目标文件的文件格式:
其余对象文件的e:\mingw-w64\mingw32\bin\nm.exe: libnetcdf_la-stub.o: File format not recognized
...等。
如果使用7zip从存档中提取了单个目标文件之一后使用file
,它将返回“ACB存档数据”。
以下是我的Makefile的编译器标志部分,如果有帮助的话:
OUTPUTLIB = -LE:/Users/Malcolm/netcdf-4.1.3-antho/lib
OUTPUTOPT = -DNETCDF
LINKOPTS = -lnetcdf -lnetcdff
FC = gfortran
OPTS = -ffree-form -ffree-line-length-none -O3 -finline-functions -fopenmp -fconvert=big-endian
OPTS += -static-libgfortran -static-libgcc
OPTS += -Wl,-Bstatic,--whole-archive -lstdc++ -lpthread -lnetcdf -lnetcdff -lgomp -lquadmath -Wl,--no-whole-archive -Wl,--stack,2147483647, --verbose
CPP = cpp -C -P -traditional -Wno-invalid-pp-token -ffreestanding
我在这个项目之前没有使用过mingw,所以可能是我缺少一些基本知识。
最佳答案
好的,我已经解决了问题。我使用的是mingw32,也曾在mingw-w64上尝试过,但没有意识到我安装了32位的i686版本。
我安装了mingw的x86_64版本,该版本用于编译我正在使用的库,并且在那里工作。
关于compiler-errors - 为什么在编译时MinGW无法识别我的目标文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62439618/