Questions regarding the compilation of a non-extension shared library
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I'm have a shared library that I would like to distribute along with my python package, written in pure C. It requires the correct installation of other software at linktime, and at runtime. The package a ctypes wrapper for SUNDIALS (a mathematical C library). I would normally simply compile my shared library on the command line as follows - --- snip: shell output 1 --- $ gcc -c -o sundials_core_aux.o sundials_core_aux.c $ gcc --shared -fPIC -Wl,-solibsundials_core_aux.so.1 -o libsundials_core_aux.so.1.0.0 sundials_core_aux.o $ /usr/lib/gcc/i686-pc-linux-gnu/3.4.6/../../../../i686-pc-linux-gnu/bin/ld: warning: creating a DT_TEXTREL in object. - --- snip --- To get rid of the DT_TEXTREL warning, I simply add -fPIC to compilation step. - --- snip: shell output 2 --- $ gcc --shared -fPIC -c -o sundials_core_aux.o $ gcc --shared -fPIC -Wl,-solibsundials_core_aux.so.1 -o libsundials_core_aux.so.1.0.0 sundials_core_aux.c $ - --- snip --- This produces no errors or warnings. Obviously this is a non-portable solution, and I'm trying to use distutils to compile the library. But when I do, using - --- snip: setup.py --- compiler = ccompiler.new_compiler() compiler.compile(['sundials_core_aux.c']) compiler.link_shared_lib(['src/sundials_core_aux.o'], compiler.library_filename('sundials_core_aux', 'shared'), 'dist') - --- snip --- The DT_TEXTREL warning appears. I've tried any number of combinations of extra_preargs and extra_postargs using '-fPIC' and '-Wl,-so...', to no avail, and equally, these are not portable arguments. Should the warning just be ignored, or is there a way I can get rid of it? Thanks, James -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFGp2nYolkHbC41Z6URAguzAJ9GWnXSVsHl6T9M126jv5e3N6hxcACguPPv aCJiGxN3M8TVJ84oYYBsc7U= =I2Vn -----END PGP SIGNATURE-----
James Dominy wrote:
Hi,
I'm have a shared library that I would like to distribute along with my python package, written in pure C. It requires the correct installation of other software at linktime, and at runtime. The package a ctypes wrapper for SUNDIALS (a mathematical C library).
You might want to take a look at OOF2. If includes a distutils command for building a shared library. I believe it tries to install the library to $prefix/lib which may not be what you want, but it might help you to find the right incantation to at least build the thing. http://www.ctcms.nist.gov/oof/oof2/index.html Will your code be open source? We have many requests for SUNDIALS wrappers on the scipy list, and it would be great to satisfy them. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
participants (2)
-
James Dominy -
Robert Kern