This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: distutils cannot link C++ code with GCC
Type: Stage:
Components: Distutils Versions:
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: barry-scott, gvanrossum, mwh, niemeyer, nnorwitz
Priority: normal Keywords:

Created on 2001-08-21 23:42 by barry-scott, last changed 2022-04-10 16:04 by admin. This issue is now closed.

Messages (6)
msg6124 - (view) Author: Barry Alan Scott (barry-scott) * Date: 2001-08-21 23:42
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
			)
		]
	)
msg6125 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2001-12-06 21:50
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.
msg6126 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2002-01-25 10:08
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!
msg6127 - (view) Author: Barry Alan Scott (barry-scott) * Date: 2002-01-27 11:42
Logged In: YES 
user_id=28665

Yes using G++ is another way to solve this.
msg6128 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2002-11-02 21:32
Logged In: YES 
user_id=33168

Barry, is this still a problem w/2.2.2?
msg6129 - (view) Author: Gustavo Niemeyer (niemeyer) * (Python committer) Date: 2002-11-05 17:04
Logged In: YES 
user_id=7887

Fixed in bug #413582.
History
Date User Action Args
2022-04-10 16:04:21adminsetgithub: 35025
2001-08-21 23:42:24barry-scottcreate