How to troubleshoot build flags

Andrew Schultz ajschult at verizon.net
Tue Jun 10 16:07:54 UTC 2014


Richard Shaw wrote:
> /usr/lib/gcc/x86_64-redhat-linux/4.8.2/../../../../lib64/crt1.o: In
> function `_start':
> (.text+0x20): undefined reference to `main'
> collect2: error: ld returned 1 exit status
> rmbadname1: Replacing "len" with "len_bn".
> /usr/lib/gcc/x86_64-redhat-linux/4.8.2/../../../../lib64/crt1.o: In
> function `_start':
> (.text+0x20): undefined reference to `main'
> collect2: error: ld returned 1 exit status
> error: Command "/usr/bin/gfortran -Wall -Wl,-z,relro -Wl,-z,relro
> /tmp/tmpom3x2m/tmp/tmpom3x2m/src.linux-x86_64-3.3/wmodule.o
> /tmp/tmpom3x2m/tmp/tmpom3x2m/src.linux-x86_64-3.3/fortranobject.o
> /tmp/tmpom3x2m/wspr1.o /tmp/tmpom3x2m/getfile.o
> /tmp/tmpom3x2m/paterminate.o /tmp/tmpom3x2m/audiodev.o
> /tmp/tmpom3x2m/tmp/tmpom3x2m/src.linux-x86_64-3.3/w-f2pywrappers.o
> thnix.o libwspr.a -L/usr/lib64 -lfftw3f -lgfortran -lportaudio -lpthread
> -lsamplerate -lpython3.3m -lgfortran -o ./w.cpython-33m.so
> <http://w.cpython-33m.so>" failed with exit status 1
> make: *** [WsprMod/w.so] Error 1

It's using the gfortran to link and then explicitly adding -lgfortran 
(twice, of course);  gfortran will do this automatically.  Also, if a 
executable has a main method in C, then you'll be more successful 
linking the program with gcc instead of gfortran (if it has a main 
program in fortran, then use gfortran to link).  It might be possible to 
go the other way, but I have never had success.

-- 
Andrew Schultz
ajs42 at buffalo.edu
http://www.cbe.buffalo.edu/schultz


More information about the devel mailing list