[MacPorts] #42777: gcc47/gcc48 - problem with linking some C++ python extensions (std::ostringstream)
MacPorts
noreply at macports.org
Sun Mar 9 13:07:45 PDT 2014
#42777: gcc47/gcc48 - problem with linking some C++ python extensions
(std::ostringstream)
----------------------+--------------------------------
Reporter: wojdyr@… | Owner: macports-tickets@…
Type: defect | Status: new
Priority: Normal | Milestone:
Component: ports | Version: 2.2.1
Keywords: | Port: gcc48
----------------------+--------------------------------
I've been tracking a problem with Boost.Python extensions built using GCC
from macports.
Here is a minimal program that shows the problem:
{{{
#include <iostream>
#include <sstream>
extern "C" void run() {
std::ostringstream o;
o << 123;
std::cout << "[" << o.str() << "]\n";
}
}}}
It runs fine when dlopen'ed from C, but not from Python (regardless if
it's system or macports or manually built Python).
{{{
$ g++-mp-4.8 -c -fPIC otest.cc
$ g++-mp-4.8 -bundle -undefined dynamic_lookup otest.o -o otest.so
$ python -c "import ctypes; ctypes.CDLL('./otest.so').run()"
[]
}}}
(I'm using ffi here to keep it simple, it's the same with python
extension).
If I replace g++-mp-4.8 with g++ when linking it works as expected:
{{{
$ g++ -bundle -undefined dynamic_lookup otest.o -o otest.so
$ python -c "import ctypes; ctypes.CDLL('./otest.so').run()"
[123]
}}}
Alternatively, if I take the linking command from g++-mp-4.8:
{{{
/opt/local/bin/ld -dynamic -arch x86_64 -bundle -macosx_version_min 10.6.8
-undefined dynamic_lookup -weak_reference_mismatches non-weak -undefined
dynamic_lookup -o otest.so -L/opt/local/lib/gcc48/gcc/x86_64-apple-
darwin10/4.8.2 -L/opt/local/lib/gcc48/gcc/x86_64-apple-
darwin10/4.8.2/../../.. otest.o -lstdc++ -no_compact_unwind -lSystem
-lgcc_ext.10.5 -lgcc -lSystem
}}}
and remove `-lstdc++`, it also works.
I'm using OSX 10.6. This problem happens with gcc47 and gcc48 from
macports, but not with GCC from xcode and clang-3.3 from macports. Is it
fixable?
--
Ticket URL: <https://trac.macports.org/ticket/42777>
MacPorts <http://www.macports.org/>
Ports system for OS X
More information about the macports-tickets
mailing list