Link errors embedding Python 3.2

C

Chris Angelico

I'm starting to feel incredibly stupid here. Hopefully someone can
point out a really obvious thing that I've missed, thus enabling me to
move forward!

Up until now, I've been embedding Python 2.6.6 in my C++ program, by
compiling with "-I/usr/include/python2.6 -lpython2.6", and all has
been well. The Python I use was installed as part of Ubuntu's setup,
and is managed by apt-get. Now, I'm trying to switch to using Python
3. so I downloaded the 3.2 sources and did the usual './configure;
make; sudo make install', then snooped to see where it had put things.
I'm now compiling with "-I/usr/local/include/python3.2m -lpython3.2m",
and it's compiling successfully (now that I've changed the function
names eg PyString --> PyBytes), but the link fails with heaps of
undefined references - as far as I can tell, every single Py*
reference is failing.

There is a libpython3.2m.a accessible, and poking around with ar and
nm shows that it does contain object files with the necessary symbols.
If I deliberately misspell the -lpython3.2m option, the link bombs
immediately, so presumably it IS finding the library. Explicitly
naming the library as ~/Python-3.2/libpython3.2m.a (or using ar to
extract them and then linking against the whole directoryful of .o
files, which does the same thing) cures the undefined references to
Py* functions, but brings in undefined refs to dlsym and openpty and
family.

Is/are there additional library/ies that I need to be linking against
for Python 3? And why is the usual -lpython3.2m not working as normal?
Is there a problem with C++ and Python? (I tried surrounding #include
"Python.h" with extern "C" { }, but to no avail.)

Hoping that someone has already done this!

Chris Angelico
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top