Paulo Santiago
Paulo Santiago

Reputation: 43

Error compiling with gfortran/gcc: crt1.o: In function `_start'

I'm executing this makefile to compile a Fortran code using gfortran, gcc, netcdf and mpich2 libraries.

When the make script executes the following command,

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

I get the following message:

/usr/lib/gcc/x86_64-redhat-linux/4.8.3/../../../../lib64/crt1.o: In function _start': (.text+0x20): undefined reference tomain' collect2: error: ld returned 1 exit status

I have found similar error messages in forums, but I didn't saw how to apply the solutions in my problem.

Could someone please guide me solving this problem?

Upvotes: 2

Views: 2235

Answers (1)

J.J. Hakala
J.J. Hakala

Reputation: 6214

If you are building a library, you might need -c flag in

.f.o:
    ${FF77}  ${FFLAGS} $<

i.e.

.f.o:
    ${FF77}  ${FFLAGS} -c $<

The same applies for

.f90.o:
    ${FF90} ${FFLAGS} -c $<
.c.o:
    ${CC} ${CFLAGS} -I$(SAM_SRC)/TIMING $(NOTIMERS) -c $<

Upvotes: 2

Related Questions