cannot find -lgpc when use pgf90?

when I install the pgf90 compiler, and use pgf90 to compiler a *.f file, the following problem occured:
/usr/bin/ld: cannot find -lpgc

what’s the problem? Thanks

Hi rainbowbluegz,

This error is caused when the linker can’t find a particular library. Since libpgc.a is a standard PGI library, it’s unclear why the linker can’t find it.

First, please verify that “libpgc.a” exists in your PGI installation’s “lib” directory. If the library isn’t there, then try re-installing.

Next, try compiling the following simple “Hello World” program with the “-v” flag (verbose) and post the output if it fails.

If the hello program links correctly, what flags are you using? Perhaps you have added an “-L” flag?

Thanks,
Mat

% cat hello.f
      print *, "Hello"
      end
% pgf90 -v hello.f

/usr/pgi/linux86-64/6.2-2/bin/pgf901 hello.f -opt 1 -nohpf -nostatic -x 19 0x400000 -quad -x 59 4 -x 59 4 -x 15 2 -x 49 0x400004 -x 51 0x20 -x 57 0x4c -x 58 0x10000 -x 124 0x1000 -x 57 0xfb0000 -x 58 0x78031040 -x 48 4608 -x 49 0x100 -x 120 0x200 -stdinc /usr/pgi/linux86-64/6.2-2/include:/usr/local/include:/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/include:/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5//include:/usr/include -def unix -def __unix -def __unix__ -def linux -def __linux -def __linux__ -def __NO_MATH_INLINES -def __x86_64__ -def __LONG_MAX__=9223372036854775807L -def '__SIZE_TYPE__=unsigned long int' -def '__PTRDIFF_TYPE__=long int' -def __THROW= -def __extension__= -def __amd64__ -def __SSE__ -def __MMX__ -def __SSE2__ -def __SSE3__ -nofreeform -vect 48 -output /tmp/pgf90tNBg5cxAQ7C9.ilm
  0 inform,   0 warnings,   0 severes, 0 fatal for MAIN
PGF90/any Linux/x86-64 6.2-2: compilation successful

/usr/pgi/linux86-64/6.2-2/bin/pgf902 /tmp/pgf90tNBg5cxAQ7C9.ilm -fn hello.f -opt 1 -x 51 0x20 -x 119 0xa10000 -x 122 0x40 -x 123 0x1000 -x 127 4 -x 127 16 -x 19 0x400000 -x 28 0x40000 -quad -x 120 0x80000000 -x 59 4 -x 59 4 -y 80 0x1000 -x 80 0x10800000 -x 124 0x1400 -y 15 2 -x 57 0x3b0000 -x 58 0x48000000 -x 49 0x100 -x 120 0x200 -astype 0 -x 124 1 -cmdline '+pgf90 hello.f -V6.2-2 -v' -asm /tmp/pgf90RNBgbAVcL7xO.s
  0 inform,   0 warnings,   0 severes, 0 fatal for MAIN
PGF90/x86 Linux/x86-64 6.2-2: compilation successful

/usr/bin/as /tmp/pgf90RNBgbAVcL7xO.s -o /tmp/pgf90dNBgjQkAU1MW.o

/usr/bin/ld /usr/lib64/crt1.o /usr/lib64/crti.o /usr/pgi/linux86-64/6.2-2/lib/trace_init.o /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5//crtbegin.o /usr/pgi/linux86-64/6.2-2/lib/f90main.o -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/pgi/linux86-64/6.2-2/lib/pgi.ld /tmp/pgf90dNBgjQkAU1MW.o -L/usr/pgi/linux86-64/6.2-2/lib -L/usr/lib64 -L/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/ -rpath /usr/pgi/linux86-64/6.2-2/lib -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl -lnspgc -lpgc -lm -lgcc -lc -lgcc /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5//crtend.o /usr/lib64/crtn.o

$cat hello.f
print *, “Hello”
end

when i compiler the hello.f using pgf90 -v, it appears:

/usr/pgi/linux86/bin/pgf901 hello.f -x 49 0x400004 -x 57 0x40 -x 58 0x31040 -nohpf -x 57 12 -x 124 0x1000 -x 51 0x20 -x 48 3328 -x 15 2 -output /tmp/pgf90rsAStx.ilm -stdinc /usr/pgi/linux86/include:/usr/local/include:/usr/i386-redhat-linux/include:/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include:/usr/include -def unix -def i386 -def linux -def unix -def inline= -def i386 -def linux -def __unix -def __i386 -def __linux -def __NO_MATH_INLINES -def linux86 -def unix -nostatic -opt 1 -vect 48
PGF90-S-0018-Illegal label field (hello.f: 1)
PGF90-S-0034-Syntax error at or near * (hello.f: 1)
PGF90-S-0018-Illegal label field (hello.f: 2)
PGF90-S-0022-Unexpected end of file - missing END statement (hello.f: 2)
0 inform, 0 warnings, 4 severes, 0 fatal for MAIN
PGF90/any Linux/x86 3.2-4a: compilation completed with severe errors
pgf90: /usr/pgi/linux86/bin/pgf901 completed with exit code 1
Unlinking
Unlinking
Unlinking /tmp/pgf908ncSsF
Unlinking /tmp/pgf90rsAStx.ilm
Unlinking /tmp/pgf90rsAStx.dwf
Unlinking hello.stb
Unlinking /tmp/pgf90rsAStx.ilm
Unlinking /tmp/pgf90rsAStx.dwf
Unlinking hello.stb
Unlinking hello.stb


what’s the problem?

As you said that maybe I add the ‘-L’ flag, then how can I cancel this flag? how to operate?

I am sure that the libpgc.a exist.

thanks in advance.

hi, mkcolg

when I make sure that the libpgc.a exists in lib, the problem of /usr/lib/ld: cannot find -lpgc disappear. Thank you very much for your help.

but run
pgf90 -v hello.f
the information is nearly the same as above, just the line of ‘cannot find -lpgc’ is missing.

what’s the problem?

I think the code that mkcolq showed was wrong (as seen by the severe error messages you saw). Note that if you don’t use correct syntax form, you’ll need to compile with -Mfree to use freeform source. Also, make sure that your PGI environment variable is set

[chulbert@fourier tmp]$ env | grep PGI
PGI=/usr/pgi
[chulbert@fourier tmp]$ cat hello.f
PROGRAM hello
print *, ‘hello’
END
[chulbert@fourier tmp]$ pgf90 -v hello.f

/usr/pgi-6.1-4/linux86-64/6.1/bin/pgf901 hello.f -opt 1 -nohpf -nostatic -x 19 0x400000 -quad -x 59 4 -x 59 4 -x 15 2 -x 49 0x400004 -x 51 0x20 -x 57 0x4c -x 58 0x10000 -x 124 0x1000 -x 57 0xfb0000 -x 58 0x78031040 -x 48 4608 -x 49 0x100 -x 120 0x200 -stdinc /usr/pgi-6.1-4/linux86-64/6.1/include:/usr/local/include:/usr/lib/gcc/x86_64-redhat-linux/4.0.2/include:/usr/lib/gcc/x86_64-redhat-linux/4.0.2//include:/usr/include -def unix -def __unix -def unix -def linux -def __linux -def linux -def inline= -def NO_INLINE -def __NO_MATH_INLINES -def x86_64 -def LONG_MAX=9223372036854775807L -def ‘SIZE_TYPE=unsigned long int’ -def ‘PTRDIFF_TYPE=long int’ -def __THROW= -def amd64 -nofreeform -vect 48 -output /tmp/pgf90aaaaaxrjaD.ilm
0 inform, 0 warnings, 0 severes, 0 fatal for hello
PGF90/any Linux/x86-64 6.1-4: compilation successful

/usr/pgi-6.1-4/linux86-64/6.1/bin/pgf902 /tmp/pgf90aaaaaxrjaD.ilm -fn hello.f -opt 1 -x 51 0x20 -x 119 0xa10000 -x 122 0x40 -x 123 0x1000 -x 127 4 -x 127 16 -x 19 0x400000 -x 28 0x40000 -quad -x 120 0x80000000 -x 59 4 -x 59 4 -y 80 0x1000 -x 80 0x10800000 -x 124 0x1400 -y 15 2 -x 57 0x3b0000 -x 58 0x48000000 -x 49 0x100 -x 120 0x200 -astype 0 -x 124 1 -cmdline ‘+pgf90 hello.f -v’ -asm /tmp/pgf90baaaaxrjaD.s
0 inform, 0 warnings, 0 severes, 0 fatal for hello
PGF90/x86 Linux/x86-64 6.1-4: compilation successful

/usr/bin/as /tmp/pgf90baaaaxrjaD.s -o /tmp/pgf90caaaaxrjaD.o

/usr/bin/ld /usr/lib64/crt1.o /usr/lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/4.0.2//crtbegin.o /usr/pgi-6.1-4/linux86-64/6.1/lib/f90main.o -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/pgi-6.1-4/linux86-64/6.1/lib/pgi.ld /tmp/pgf90caaaaxrjaD.o -L/usr/pgi-6.1-4/linux86-64/6.1/lib -L/usr/lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.0.2/ -rpath /usr/pgi-6.1-4/linux86-64/6.1/lib -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl -lc -lnspgc -lpgc -lm -lgcc -lc -lgcc /usr/lib/gcc/x86_64-redhat-linux/4.0.2//crtend.o /usr/lib64/crtn.o
Unlinking /tmp/pgf90aaaaaxrjaD.ilm
Unlinking /tmp/pgf90baaaaxrjaD.s
Unlinking /tmp/pgf90caaaaxrjaD.o

Geez… can’t a guy use slightly older syntax? ;-)

Actually, the program I used is a perfectly valid Fortran 95 program. Programs ending with a “.f” indicate fixed form format and requires six characters before each statement (as I did in my example). My mistake was forgetting that a user would simply cut and paste from the post which removes the spaces. Next time, I’ll use a “.f90” extension or compile with “-Mfree” which indicate free form.

  • Mat

My post was worse; I posted the freeform and compiled the fixed ;-). I’m not a fortran expert, so I guess I didn’t realize that you did not have to start a program with a PROGRAM statement.

While the program statement is optional, it is recommended. For toy programs I tend to be a bit lazy and leave it out. Please continue to use PROGRAM and ignore my bad habits!