
On Thu, 18 Feb 2010 22:29:39 +0900 David Cournapeau <cournape@gmail.com> wrote:
On Thu, Feb 18, 2010 at 10:22 PM, Nils Wagner <nwagner@iam.uni-stuttgart.de> wrote:
On Thu, 18 Feb 2010 11:55:07 +0100 Matthieu Brucher <matthieu.brucher@gmail.com> wrote:
Ok I have extracted the *.o files from the static library.
Applying the file command to the object files yields
ELF 64-bit LSB relocatable, AMD x86-64, version 1 (SYSV), not stripped
What's that supposed to mean ?
It means that each object file is an object file compiled with -fPIC, so you just have to make a shared library (gfortran -shared *.o -o libmysharedlibrary.so)
Then, you can try to open the library with ctypes. If something is lacking, you may have to add -lsome_library to the gfortran line.
Matthieu -- Information System Engineer, Ph.D. Blog: http://matt.eifelle.com LinkedIn: http://www.linkedin.com/in/matthieubrucher
O.k. I tried
gfortran -shared *.o -o libmysharedlibrary.so
/usr/bin/ld: dxop.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
The message is pretty explicit: it is not compiled with -fPIC, there is nothing you can do, short of requesting a shared library from the software vendor.
David
Hi, Meanwhile I received a static library (including -fPIC support) from the software vendor. Now I have used ar x test.a gfortran -shared *.o -o libtest.so -lg2c to build a shared library. The additional option -lg2c was necessary due to an undefined symbol: s_cmp Now I am able to load the shared library from ctypes import * my_lib = CDLL('test.so') What are the next steps to use the library functions within python ? Nils