I recently started using f2py and python2.7 for working on some codes related to an ocean model (ROMS) in Fortran. My workstation specifics are Ubuntu 16.04 with python2.7, anaconda2 and gfortran. I have netcdf and hdf5 libraries installed as well.
The instruction in the makefile is the following (in one line):
$(F2PY) --fcompiler=gfortran --f90flags=$(F2PY_F90_FLAG) $(F2PY_LIB) $(F2PY_INCLUDE) $(OBJF2PY) -m -c scrip pyscrip.f90
where:
During compilation, I am getting an error as given:
/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
I could not understand why this error is showing up. Is the instruction in the correct order? Does it have something to do with the compiler flags? Is there any other include file that the code needs (other than netcdf.inc), or any other library (other than netcdf and hdf5 libs)?
The answer is given on GitHub and is to add the -shared
option to your LDFLAGS
environment variable. Try LDFLAGS="-shared $LDFLAGS"
before running f2py
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.