File with unknown suffix passed to linker

make decode_bufr

gives these errors:

pgf90 decode_bufr.c -o decode_bufr  -L /opt/pgi/linux86/7.0/lib/pgi.ld -L/usr/local/lib -lemos -L /opt/pgi/linux86/7.0/lib -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgftnrtl -lc -lnspgc -lrt -lpgc -lpgf90 -Wl,-rpath /opt/pgi/linux86/7.0/lib
NOTE: your trial license will expire in 12 days, 8.09 hours.
File with unknown suffix passed to linker: /opt/pgi/linux86/7.0/lib
decode_bufr.o: In function `main':
decode_bufr.c:(.text+0x10): multiple definition of `main'
/opt/pgi/linux86/7.0-5/lib/f90main.o:f90main.c:(.text+0x10): first defined here
/usr/bin/ld: Warning: size of symbol `main' changed from 138 in /opt/pgi/linux86/7.0-5/lib/f90main.o to 1312 in decode_bufr.o
/opt/pgi/linux86/7.0-5/lib/f90main.o: In function `main':
f90main.c:(.text+0x77): undefined reference to `MAIN_'
make: *** [decode_bufr] Error 2

makefile is like this:

# Makefile for compiling and linking C grib decoding tools with LIBEMOS 
# compiled with the PGI Fortran compilers

TARGETS  = all clean decode_grib

SOURCES  = decode_grib.c decode_bufr.c

PGILIB52 = -L /opt/pgi/linux86/7.0/lib -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgftnrtl -lc -lnspgc -lrt -lpgc -lpgf90
PGILDFLAGS52  = -Wl,-rpath /opt/pgi/linux86/7.0/lib

PGILDFLAGS52_2=-L /opt/pgi/linux86/7.0/lib/pgi.ld

EMOSLIB52  = -L/usr/local/lib -lemos


CC       = pgf90
LD       = pgf90


all: decode_grib decode_bufr

	rm -f decode_grib.o decode_grib

decode_grib:  decode_grib.c
	$(CC) decode_grib.c -o decode_grib $(CFLAGS) $(LDFLAGS)

decode_grib52:  decode_grib.c
	$(CC) decode_grib.c -o decode_grib52 $(CFLAGS) $(LDFLAGS52)

decode_bufr:  decode_bufr.c
	$(CC) decode_bufr.c -o decode_bufr $(CFLAGS) $(LDFLAGS)

decode_bufr52: decode_bufr.c 
	$(CC) decode_bufr.c -o decode_bufr52 $(CFLAGS) $(LDFLAGS52)



I see a couple problems. You need to add “-Mnomain” since your “main” program is written in C. Without “-Mnomain”, pgf90 will add it’s “main” causing the multiple definition error.

The second error is you need to add a “,” after rpath in order for the rpath directory to be passed to the linker: “-Wl,-rpath,/opt/pgi/linux86/7.0/lib”.

Note that since you are using pgf90 to link, you do not need to add any PGI library or the rpath. This is done automatically by the driver (pgf90). It doesn’t hurt, but is redundant.

  • Mat