[f2py] More precise: gfortran with static and shared libs (fwd)

KASSBOHM <[email protected]> Sat, 1 Sep 2012 11:07:44 +0300 (EEST)
Newsgroups gmane.comp.python.f2py.user
Message-ID <alpine.DEB.2.02.1209011058530.2692@thnkpd>
Sorry, my question from yesterday was maybe not precise enough...Actually, this 
is maybe more of a linker problem, I guess... I try to be more precise now:

As I said, I have:

lib1:  a STATIC lib (3rd party)

libs2: SHARED libs of gfortran

lib3:  another STATIC lib (3rd party)

And I want to build a shared object with this for the use with Python.

Now I do:

/usr/bin/gfortran -Wall -Wall -shared ./src.linux-x86_64-2.7/mymodule.o 
./src.linux-x86_64-2.7/fortranobject.o ./xxx.o -L./Libs -llib1 -lgfortran 
-llib3 -o ./my.so

And I get the following error:

--- snip

/usr/bin/ld: ./Libs/lib3.a(string_intrinsics.o): relocation R_X86_64_32 against 
`.rodata.str1.1' can not be used when making a shared object; recompile with 
-fPIC

./Libs/lib3.a: could not read symbols: Bad value

collect2: ld returned 1 exit status

--- snip

But I cannot recompile lib3... What can I do?






---------- Forwarded message ----------
Date: Fri, 31 Aug 2012 16:14:15 +0300 (EEST)
From: KASSBOHM <[email protected]>
Reply-To: For users of the f2py program <f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]>
To: f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]
Subject: [f2py] gfortran with static and shared libs

I have so Fortran sources, I would like to use from Python. I would like to link
my objects with:

lib1:  a STATIC lib (3rd party)

libs2: SHARED libs of gfortran

lib3:  another STATIC lib (3rd party)

More precisely, I would like to search all those libs in that order. That is,
for example: If there is a symbol or function in libs2 AND in lib3, I would like
to use that of libs2. But there are symbols in lib3, which I need.

Can I do such things with f2py? If yes: How? Can anybody help?


I tried the following:

***A***

If I do: f2py ... -llib1 -lib3, I get:

/usr/bin/gfortran -Wall -Wall -shared ...xxxmodule.o .../fortranobject.o
obj.o  obj.o ...-Lpath -llib1 -lib3 -lgfortran -o ./xxx.so

/usr/bin/ld: path/lib3.a(stop.o):

relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a
shared object; recompile with -fPIC

path/lib3.a: could not read symbols: Bad value

***B***

If I do: f2py ... -llib1, I get, when importing the module:

ImportError: ./xxx.so: undefined symbol: _gfortran_copy_string

Sure, I did not link lib3. That's why gfortran_copy_string is missing. It's
seems not to be included in libs2. But 3rd party says: It is included in lib3.



_______________________________________________
f2py-users mailing list
f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]
http://cens.ioc.ee/mailman/listinfo/f2py-users