Issue 454030: distutils cannot link C++ code with GCC (original) (raw)
It is mandatory to link C++ code against -lstdc++ -lm when creating an extension.
distutils does not do this in 2.1.1
Here is a setup.py for Python CXX that works around the problem, but it would be better for distutils to understand enough about C++ to do the right thing. THen the code for other compilers could be added. But GCC is important enough to do first.
You can get the CXX sources from http://sourceforge.net/projects/cxx/
from distutils.core import setup, Extension
if os.name == 'posix': CXX_libraries = ['stdc++','m'] else: CXX_libraries = []
setup(name="pycxx_demo", version="1.0", ext_modules= [Extension( "example", sources = [ "Demo/example.cxx", "Demo/python.cxx", "Demo/range.cxx", "Demo/rangetest.cxx",
"Src/cxx_extensions.cxx",
"Src/cxxextensions.c",
"Src/cxxsupport.cxx",
"Src/IndirectPythonInterface.cxx" ],
include_dirs = [ ".", "Demo" ],
libraries = CXX_libraries
)
]
)