[Distutils] Questions regarding the compilation of a non-extension shared library

James Dominy james at NBN.ac.za
Wed Jul 25 17:18:48 CEST 2007


-----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-----


More information about the Distutils-SIG mailing list