[英]compilation error with f2py and gfortran: undefined reference to `main'
我最近开始使用 f2py 和 python2.7 来处理与 Fortran 中的海洋模型 (ROMS) 相关的一些代码。 我的工作站细节是 Ubuntu 16.04,带有 python2.7、anaconda2 和 gfortran。 我也安装了 netcdf 和 hdf5 库。
makefile 中的指令如下(在一行中):
$(F2PY) --fcompiler=gfortran --f90flags=$(F2PY_F90_FLAG) $(F2PY_LIB) $(F2PY_INCLUDE) $(OBJF2PY) -m -c 脚本 pyscrip.f90
在哪里:
在编译过程中,我收到一个错误:
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In function _start: (.text+0x20): undefined reference to 'main' collect2: error: ld returned 1 exit status
我不明白为什么会出现这个错误。 指令的顺序是否正确? 它与编译器标志有关吗? 是否有代码需要的任何其他包含文件(netcdf.inc 除外)或任何其他库(netcdf 和 hdf5 库除外)?
答案在GitHub 上给出,是将-shared
选项添加到LDFLAGS
环境变量中。 在运行f2py
之前尝试LDFLAGS="-shared $LDFLAGS"
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.