Dynamic linking problem x86_64 platform

Hi,

linking works if I use the loader directly:

/usr/bin/ld /usr/lib64/crti.o /usr/lib64/gcc/x86_64-mandrake-linux-gnu/3.4.1/crtbeginS.o
-m elf_x86_64 -dynamic-linker
/lib64/ld-linux-x86-64.so.2 build/temp.linux-x86_64-2.3/build/src/splinemodule.o \ build/temp.linux-x86_64-2.3/build/src/fortranobject.o build/temp.linux-x86_64-2.3/prec.o\ build/temp.linux-x86_64-2.3/spline.o\ build/temp.linux-x86_64-2.3/build/src/spline-f2pywrappers2.o
-o build/lib.linux-x86_64-2.3/spline.so -L/opt/pgi/linux86-64/5.2/libso -L/usr/lib64
-L/usr/lib64/gcc/x86_64-mandrake-linux-gnu/3.4.1
-rpath /opt/pgi/linux86-64/5.2/libso -Bdynamic -shared -lpgf90 -lpgf90_rpm1 -lpgf902\ -lpgf90rtl -lpgftnrtl -lc -lpgc -lm -lgcc -lc -lgcc
/usr/lib64/gcc/x86_64-mandrake-linux-gnu/3.4.1/crtendS.o /usr/lib64/crtn.o

doesn’t work for
pgf90 -v -Bdynamic -shared build/temp.linux-x86_64-2.3/build
/src/splinemodule.o build/temp.linux-x86_64-2.3/build/src/fortranobject
.o build/temp.linux-x86_64-2.3/prec.o build/temp.linux-x86_64-2.3/spline
.o build/temp.linux-x86_64-2.3/build/src/spline-f2pywrappers2.o -o
build/lib.linux-x86_64-2.3/spline.so\n\n/usr/bin/ld /usr/lib64/crti
.o /usr/lib64/gcc/x86_64-mandrake-linux-gnu/3.4.1/crtbeginS.o -m elf_x
86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 build/temp.linux-x
86_64-2.3/build/src/splinemodule.o build/temp.linux-x86_64-2.3/build
/src/fortranobject.o build/temp.linux-x86_64-2.3/prec.o build/temp.linux
-x86_64-2.3/spline.o build/temp.linux-x86_64-2.3/build/src/spline-f2pywrapp
ers2.o -o build/lib.linux-x86_64-2.3/spline.so -L/opt/pgi/linux86-64
/5.2/lib -L/usr/lib64 -L/usr/lib64/gcc/x86_64-mandrake-linux-gnu/3.4
.1 -rpath /opt/pgi/linux86-64/5.2/lib -Bdynamic -shared -lpgf90 -lpgf
90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl -lc -lnspgc -lpgc -lm -lgcc
-lc -lgcc /usr/lib64/gcc/x86_64-mandrake-linux-gnu/3.4.1/crtendS.o
/usr/lib64/crtn.o\n/usr/bin/ld: /opt/pgi/linux86-64/5.2/lib/libpgf

90.a(ftnexit.o): relocation R_X86_64_32S against `pghpf_0_’ can not
be used when making a shared object; recompile with -fPIC\n/opt/pgi
/linux86-64/5.2/lib/libpgf90.a: could not read symbols: Bad value\npgf
90-Fatal-linker completed with exit code 1

note that for the working ld command I exchanged /opt/pgi/linux86_64/5.2/lib with
/opt/pgi/linux86_64/5.2/libso

What is the problem? Why doesnt the pgf90 -shared use the libso path?

Regards

Thomas

Hi Thomas,

“-shared” is just passed directly to the linker. To get the “libso” library directory please add the “-fpic” flag to your link line. Also, you could change your “-L/opt/pgi/linux86-64/5.2/lib” and “-rpath /opt/pgi/linux86-64/5.2/lib” flags to “-L/opt/pgi/linux86-64/5.2/libso” and “-rpath /opt/pgi/linux86-64/5.2/libso”.

Hope this helps,
Mat

Thanks Mat,

linking worked with the -fpic flag.

Thanks

Thomas