我正在执行这个makefile使用 gfortran、gcc、netcdf 和 mpich2 库编译 Fortran 代码。
当make脚本执行以下命令时,
gfortran -O3 -I/home/santiago/Install/mpich2_sam/include -I/home/santiago/Install/netcdf_sam/include /home/santiago/Modeling/SAM6.8.2/SRC/fft.f
我收到以下消息:
/usr/lib/gcc/x86_64-redhat-linux/4.8.3/../../../../lib64/crt1.o: In function
_start': (.text+0x20): undefined reference to
main' collect2: error: ld returned 1 exit status
我在论坛中发现了类似的错误消息,但我没有看到如何在我的问题中应用这些解决方案。
有人可以指导我解决这个问题吗?
最佳答案
如果您正在构建库,则可能需要 -c
标志
.f.o:
${FF77} ${FFLAGS} $<
即
.f.o:
${FF77} ${FFLAGS} -c $<
同样适用
.f90.o:
${FF90} ${FFLAGS} -c $<
.c.o:
${CC} ${CFLAGS} -I$(SAM_SRC)/TIMING $(NOTIMERS) -c $<
关于linux - 使用 gfortran/gcc : crt1. o 编译时出错:在函数 `_start' 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34992899/