[Distutils] Using boost with distutils
Pearu Peterson
Pearu Peterson <pearu@cens.ioc.ee>
Tue Mar 6 14:14:01 2001
Hi!
I am trying to use distutils with boost (www.boost.org) on MD 7.0 Linux
and with gcc 2.95.2.
When compiling/linking C++ codes, distutils uses gcc compiler. But then
importing shared module fails (it cannot find `cerr').
When I manually used g++ for compiling/linking, import succeeded.
Now I use the following code fragment
++++++++++++++++++++++++++++++++++++++++++++++
from distutils import sysconfig
save_init_posix = sysconfig._init_posix
def my_init_posix():
print 'my_init_posix: changing gcc to g++'
save_init_posix()
g = sysconfig._config_vars
g['CC'] = 'g++'
g['LDSHARED'] = 'g++ -shared'
sysconfig._init_posix = my_init_posix
+++++++++++++++++++++++++++++++++++++++++++++
in my setup.py file.
I am wondering if there is a "nicer" way to change compiler and
linker program in setup.py?
If a package contains both C and C++ codes, then the above will not
work. Any ideas how to build such mixed extension modules?
And I'll appreciate an example setup.py that uses boost.
Pearu