[Python-Dev] Linux Python linking with G++?

David Abrahams dave at boost-consulting.com
Sat Jul 9 03:46:42 CEST 2005


"Martin v. Löwis" <martin at v.loewis.de> writes:

> David Abrahams wrote:
>>>If there is some library with such objects that happens to get
>>>wrapped and dynamically linked into a Python interpreter 
>> 
>> 
>> Whoa there.  How would that ever happen under ordinary circumstances?
>> Doesn't Python's makefile control what gets linked to Python?
>
> Not entirely. By extending Modules/Setup 

You mean 
http://cvs.sourceforge.net/viewcvs.py/python/python/dist/src/Modules/Setup.dist?view=markup
?

> e.g. in the way freeze works), it is well possible to have
> additional extension modules linked into the Python interpreter,
> extension modules which are not part of the standard Python
> distribution.
>
> In fact, before Python supported dynamic loading of extension
> modules, this was the *only* way to use non-standard extension
> modules. You always had to build your own version of the Python
> interpreter. I believe ccpython.cc dates back to these times.

That explains a lot.  

I contend that either:

   a.  Anyone making that sort of extension with a C++ module should
   explicitly request --with-cxx, or

   b.  The python build system should automatically detect that
   --with-cxx is needed based on the presence of C++ extension
   modules.

Frankly I think b. would require an impractical amount of work and,
speaking as an author of C++ extension modules, I don't think a. is
much of a burden to impose.

>> If there's someone around here who is responsible for this change and
>> knows its real rationale, can (s)he please tell me what it is?  If
>> not, can we please change things back so Python doesn't get linked to
>> the C++ runtime by default?
>
> ccpython.cc and --with-cxx was first published in Python 1.6, and
> hasn't changed much since. So for some of you, it has "always" been
> there. It was contributed by Geoff Furnish.
>
> What *has* changed now is that the configure test suddenly
> determines that you need to link with g++ on Linux if main was
> compiled with g++.  This was not the case before, but now is (since
> g++ 3.2 or something).

I see.  Well, everything has become clear, thank you.  My proposed
remedy hasn't changed, though.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com


More information about the Python-Dev mailing list