[Distutils] Linking C++ under Linux

Bill Spotz wfspotz at sandia.gov
Fri Jan 9 17:53:05 EST 2004

I am developing a set of extension modules for python written in C++ 
and have successfully written a setup.py that works on my mac.  
Portability is important, though, and under Linux, the linking command 
I get from distutils appears to be not what I want.

Specifically, on the mac, the compile command from distutils is gcc 
with the appropriate command line options and the link command is c++.  
On the Linux machine, gcc is both the compile and linking command, and 
when the module is loaded, I get

ImportError: ../build/lib.linux-i686-2.2/PyTrilinos/_Epetra.so: 
undefined symbol: endl__FR7ostream

which sure looks like a missing c++ library to me.

In my searching through distutils documentation, all I can find is a 
warning to "Be sure to use appropriate extensions to distinguish C++ 
source files: .cc and .cpp seem to be recognized by both Unix and 
Windows compilers."  But changing my suffix from .cxx to .cpp didn't 
help.  (I was using .cxx because that is the default suffix produced by 
SWIG -- but I'm currently calling swig via a Makefile because distutils 
doesn't appear to be robust enough yet to handle everything I need it 
to do.)

System info:
sahp4960(41)$ uname -a
Linux sahp4960 2.4.18-17.7.xsmp #1 SMP Tue Oct 8 12:37:04 EDT 2002 i686 

Python info:
sahp4960(42)$ python
Python 2.2.1 (#1, May 14 2002, 16:46:34)
[GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-98)] on linux2

[It just occurred to me that this could be a python version issue, as 
my working mac version is under python 2.3.  I'll be looking into this, 
but would still appreciate a response.]


** Bill Spotz                                              **
** Sandia National Laboratories  Voice: (505)845-0170      **
** P.O. Box 5800                 Fax:   (505)284-5451      **
** Albuquerque, NM 87185-0316    Email: wfspotz at sandia.gov **

More information about the Distutils-SIG mailing list