recompiling with -fPIC does not work

I performed the two steps but compiler exits with error.
My steps are here:

$ pgf77 -fPIC -c dummy.F
$ pgf77 -fPIC -shared -o util.o dummy.o
/usr/bin/ld: dummy.o: relocation R_X86_64_PC32 against `__pgio_ini’ can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value

How to solve it?
Thanks.

Hi xiezhq,

What compiler version are you using? Which OS? Also, what is the output of the command “pgf77 -fPIC -shared -o util.o dummy.o -v”? Is “dummy.F” small enough that you post it?

Thanks,
Mat

Hi mkcolg,

Thanks for your reply.

Compiler: PGI 7.0.6 version
OS: 2.6.9-34.ELsmp #1 SMP x86_64 x86_64 x86_64 GNU/Linux

I used hello.f instead of dummy.F, the error still happened.
$pgf77 -fPIC -c hello.f
$pgf77 -fPIC -shared -o util.so hello.o -v

/usr/bin/ld /usr/lib64/crti.o /picb/home2/xiezhq/Applications/pgi/linux86-64/7.0-6/libso/trace_init.o /usr/lib/gcc/x86_64-redhat-linux/3.4.5/crtbeginS.o -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /picb/home2/xiezhq/Applications/pgi/linux86-64/7.0-6/lib/pgi.ld -L/picb/home2/xiezhq/Applications/pgi/linux86-64/7.0-6/libso -L/picb/home2/xiezhq/Applications/pgi/linux86-64/7.0-6/lib -L/usr/lib64 -L/usr/lib/gcc/x86_64-redhat-linux/3.4.5 -rpath /picb/home2/xiezhq/Applications/pgi/linux86-64/7.0-6/libso -rpath /picb/home2/xiezhq/Applications/pgi/linux86-64/7.0-6/lib hello.o -o util.so -shared -lpgftnrtl -lnspgc -lpgc -lrt -lpthread -lm -lgcc -lc -lgcc /usr/lib/gcc/x86_64-redhat-linux/3.4.5/crtendS.o /usr/lib64/crtn.o
/usr/bin/ld: hello.o: relocation R_X86_64_PC32 against `__pgio_ini’ can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
pgf77-Fatal-linker completed with exit code 1

Hi xiezhq,

What OS distribution are you using? CentOS? Debian?

Another user has a similar problem on Debian (See: HERE) but I have been unable to recreate either error here.

  • Mat

The OS is redhat.

“uname -a” outputs:
2.6.9-34.ELsmp #1 SMP x86_64 x86_64 x86_64 GNU/Linux

“dmesg” outputs:
Linux version 2.6.9-34.ELsmp (bhcompile@hs20-bc1-1.build.redhat.com) (gcc version 3.4.5 20051201 (Red Hat 3.4.5-2)) #1 SMP

When I performed the same thing using g77. it works fine.

$g77 -fPIC -c hello.f
$g77 -shared -o hello.so hello.o

But pgi does not work well.

$pgf77 -fPIC -c hello.f
$pgf77 -shared -o hello.so hello.o

It reported error:
/usr/bin/ld: hello.o: relocation R_X86_64_PC32 against `__pgio_ini’ can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value

Hi xiezhq,

We were able finally reproduce the problem and found a solution. The fix will be available in PGI 7.0-7 currently scheduled for release on August 2th, 2007.

  • Mat