[英]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.