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

David Abrahams dave at boost-consulting.com
Fri Jul 8 00:32:26 CEST 2005


Skip Montanaro <skip at pobox.com> writes:

>     >> I believe it's so that people can link in libraries written in C++
>     >> and have them initialized properly.
>
>     Dave> Can you give specifics?  What do you mean by "link in?"  Do you
>     Dave> mean "statically link into the Python interpreter," or something
>     Dave> else?
>
> Probably not.  I'm not a C++ guy.  My understanding is that global (maybe
> static?) C++ objects need the help of C++'s version of crt0 to get properly
> initialized at program start.  

Yes.

> 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?

> that was linked with a regular C linker (and thus had a C crt0),
> that initialization wouldn't happen.

Right, and linking would fail, IIRC.  It seems to me that if someone
decides to build a wacky Python executable that links in C++ code
directly, they can afford to use a configure option.  There's no need
to punish all the other writers of C++ extension modules out there by
tying the default build of Python to a particular version of
libstdc++.

>     Dave> Boost.Python is a library written in C++ and I've never had
>     Dave> trouble using it with a Python executable... until I ran into a
>     Dave> Python that was linked with libstdc++!
>
> Sorry, I can't help.  I'm just recounting my remembering of the
> reasons for C++ linkage.  Personally, I avoid C++ as much as I
> can...

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?

Thanks,

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


More information about the Python-Dev mailing list