[Python-bugs-list] [ python-Bugs-454030 ] distutils cannot link C++ code with GCC

noreply@sourceforge.net noreply@sourceforge.net
Sat, 02 Nov 2002 13:32:04 -0800


Bugs item #454030, was opened at 2001-08-21 19:42
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=454030&group_id=5470

Category: Distutils
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Barry Alan Scott (barry-scott)
Assigned to: Nobody/Anonymous (nobody)
Summary: distutils cannot link C++ code with GCC

Initial Comment:
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
			)
		]
	)


----------------------------------------------------------------------

>Comment By: Neal Norwitz (nnorwitz)
Date: 2002-11-02 16:32

Message:
Logged In: YES 
user_id=33168

Barry, is this still a problem w/2.2.2?

----------------------------------------------------------------------

Comment By: Barry Alan Scott (barry-scott)
Date: 2002-01-27 06:42

Message:
Logged In: YES 
user_id=28665

Yes using G++ is another way to solve this.


----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2002-01-25 05:08

Message:
Logged In: YES 
user_id=6656

Is this the same problem as

[ #413582 ] g++ must be called for c++ extensions

?  Not a rhetorical question, I would like to know!

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-12-06 16:50

Message:
Logged In: YES 
user_id=6380

Nobody at PL understands distutils well enough to do this,
so lowering the priority -- there's no way this will hold up
the release.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=454030&group_id=5470