libpgc not found

make decode_bufr

gives me the error:

gcc decode_bufr.c -o decode_bufr  -L/usr/local/lib -lemos  -L/opt/pgi/linux86/6.2/lib -lpgc -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgftnrtl -lpgsse1 -lpgsse2 -lnspgc -Wl,-rpath /opt/pgi/linux86/6.2/lib
/usr/lib/gcc/i586-suse-linux/4.1.2/../../../../i586-suse-linux/bin/ld: cannot find -lpgc
collect2: ld returned 1 exit status
make: *** [decode_bufr] Error 1

my Makefile is:

#
# 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

PGILIB62 = -L/opt/pgi/linux86/6.2/lib -lpgc -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgftnrtl -lpgsse1 -lpgsse2 -lnspgc
PGILDFLAGS62  = -Wl,-rpath /opt/pgi/linux86/6.2/lib 

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

PGILD62   = $(PGILIB62) $(PGILDFLAGS62)

CC       = gcc
CFLAGS   = 
LD       = gcc

LDFLAGS62 = $(EMOSLIB62) $(PGILD62)
LDFLAGS  = $(LDFLAGS62)


all: decode_grib decode_bufr

clean:
	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_grib62:  decode_grib.c
	$(CC) decode_grib.c -o decode_grib62 $(CFLAGS) $(LDFLAGS62)

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)

decode_bufr62: decode_bufr.c 
	$(CC) decode_bufr.c -o decode_bufr62 $(CFLAGS) $(LDFLAGS62)

why is libpgc.a not in the lib? if i clean -lpgc from makefile, this time i have hundreds of “undefined reference to…” errors.

thanx

Hi asilter,

why is libpgc.a not in the lib?

I’m not sure what you mean. Can you please rephrase the question?

if i clean -lpgc from makefile, this time i have hundreds of “undefined reference to…” errors.

Yes, this would be expected since libpgc contains the PGI C runtime libraries and the PGI Fortran libraries call several functions in this library.

Thanks,
Mat

I assume you had a successful install of the compilers and libpgc.so and libpgc.a are
present in /opt/pgi/linux86/6.2/lib. If not, check the release notes, to determine if the
gcc and glibc version on your system is supported.

If it is present (does hello.c compile and link with pgcc?), then here is what I do to determine what PGI libs to link with gcc.

% pgf90 -dryrun x.o
Reading rcfile /tmp/pgi625/linux86/6.2/bin/.pgf90rc
Reading rcfile /tmp/pgi625/linux86/6.2/bin/nativerc
Reading rcfile /tmp/pgi625/linux86/6.2/bin/fnativerc
Reading rcfile /tmp/pgi625/linux86/6.2/bin/x86rc
Reading rcfile /tmp/pgi625/linux86/6.2/bin/x8632rc
Reading rcfile /tmp/pgi625/linux86/6.2/bin/lin86rc
Reading rcfile /tmp/pgi625/linux86/6.2/bin/lin8632rc
Reading rcfile /tmp/pgi625/linux86/6.2/bin/iparc
Reading rcfile /tmp/pgi625/linux86/6.2/bin/pgf90rc
Reading rcfile /tmp/pgi625/linux86/6.2/bin/pgftnrc
Reading rcfile /tmp/pgi625/linux86/6.2/bin/localrc
Skipping .pglocalrc.borer (not found)
Skipping siterc (not found)
Skipping siterc.borer (not found)
Skipping .mypgf90rc (not found)

/usr/bin/ld /usr/lib/crt1.o /usr/lib/crti.o /tmp/pgi625/linux86/6.2/lib/trace_init.o /usr/lib/gcc/i586-suse-linux/4.0.2//crtbegin.o /tmp/pgi625/linux86/6.2/lib/f90main.o -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 /tmp/pgi625/linux86/6.2/lib/pgi.ld x.o -L/tmp/pgi625/linux86/6.2/lib -L/usr/lib -L/usr/lib/gcc/i586-suse-linux/4.0.2/ -rpath /tmp/pgi625/linux86/6.2/lib -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl -lpgsse1 -lpgsse2 -lnspgc -lpgc -lm -lgcc -lc -lgcc /usr/lib/gcc/i586-suse-linux/4.0.2//crtend.o /usr/lib/crtn.o

And from this I know that
-L/opt/linux86/6.2/lib -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl -lpgsse1 -lpgsse2 -lnspgc -lpgc -lm -lgcc -lc -lgcc

should be added to the end of the link line, though ‘-lm -lgcc -lc -lgcc’ is probably
not necessary in gcc.