Compilation error pgi

make decode_bufr

shell command gives these errors on following lines.

Error lines :

gcc decode_bufr.c -o decode_bufr -L/usr/local/lib -lemosR64 -L/opt/pgi/linux86-64/6.2/lib -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl -lc -lnspgc -lpgc -Wl,-rpath /opt/pgi/linux86-64/6.2/lib
/opt/pgi/linux86-64/6.2/lib/libpgf90rtl.a(ftncharsup.o)(.text+0x552): In function `ftn_str_malloc':
: undefined reference to `__hpf_exit'
/opt/pgi/linux86-64/6.2/lib/libpgf90rtl.a(utils3f.o)(.text+0xb4): In function `__isatty3f':
: undefined reference to `__hpfio_find_unit'
/opt/pgi/linux86-64/6.2/lib/libpgf90rtl.a(utils3f.o)(.text+0x104): In function `__getfile3f':
: undefined reference to `__hpfio_find_unit'
collect2: ld returned 1 exit status
make: *** [decode_bufr] Error 1

and this is the makefile :

# 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-64/6.2/lib -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl -lc -lnspgc -lpgc
PGILDFLAGS52 = -Wl,-rpath /opt/pgi/linux86-64/6.2/lib

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


CC = gcc
LD = gcc


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)

why am i getting this error?


Hi asilter,

While I don’t know exactly why your getting this error, try adding a second “-lpgf90” at the end of the link line. Another options is to use pgcc instead of gcc and add the flag “-libpgf90libs” to add all needed Fortran runtime libraries.

Hope this helps,