linking python libraries fails in focal

Asked by Sampsa Riikonen

My code builds allright at your server farm for Bionic, but when sending __exactly the same code__ for Focal, the linking fails.

I get stuff like "undefined reference to `PyImport_ImportModule'" and similar error messages to all Python C API calls.

This works OK:

https://launchpadlibrarian.net/494654726/buildlog_ubuntu-bionic-amd64.valkka_0.18.0-0ubuntu1-bionicppa1_BUILDING.txt.gz

Here the linking fails:

https://launchpadlibrarian.net/494654584/buildlog_ubuntu-focal-amd64.valkka_0.18.0-0ubuntu1-focalppa1_BUILDING.txt.gz

As I emphasized, it's exactly the same code. I guess I have to install focal on an extra laptop and try to compile "manually"..

Question information

Language:
English Edit question
Status:
Answered
For:
Launchpad itself Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:

This question was reopened

Revision history for this message
Colin Watson (cjwatson) said :
#1

You don't need a separate machine. https://wiki.ubuntu.com/SimpleSbuild should let you set up a build environment for focal on your bionic system, and then you can debug the problem interactively. Try that first; if you're still stuck after that then we can possibly have a look.

Revision history for this message
Sampsa Riikonen (sampsa-riikonen) said :
#2

I'll be damned..

pkg-config is not correctly configured for python3-dev in ubuntu 20..!

In LTS 18:

pkg-config python3 --libs

gives

-lpython3.6m

In LTS 20:

it gives nothing..!

I wonder where should I file a bug report about this one..

Revision history for this message
Sampsa Riikonen (sampsa-riikonen) said :
#3
Revision history for this message
Colin Watson (cjwatson) said :
#4

OK - that looks like it should give you enough to go on, so marking this as Answered again, unless there's more for us to do.

Revision history for this message
Sampsa Riikonen (sampsa-riikonen) said :
#5

I do this cmake bs in my CMakeLists.txt:

exec_program(python3-config ARGS --includes OUTPUT_VARIABLE PYTHON_INCLUDE_DIRS_TMP) # this bullshit must be parsed
exec_program(python3-config ARGS --libs OUTPUT_VARIABLE PYTHON_LIBRARIES_TMP)
string(REPLACE "-l" " " PYTHON_LIBRARIES_TMP ${PYTHON_LIBRARIES_TMP})
string(REPLACE " " ";" PYTHON_LIBRARIES ${PYTHON_LIBRARIES_TMP})
string(REPLACE "-I" " " PYTHON_INCLUDE_DIRS_TMP ${PYTHON_INCLUDE_DIRS_TMP})
string(REPLACE " " ";" PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS_TMP})

seems to fix the issue at least on my ubuntu 20 laptop

Revision history for this message
Sampsa Riikonen (sampsa-riikonen) said :
#6

python3-config --libs

and

python3-config --ldflags

Give completely different answers in 18.04 and 20.04 ...!

In 18.04 the correct answer is given with "--libs" while in 20.04 it should be "--ldflags"

Any help appreciated..

Revision history for this message
Colin Watson (cjwatson) said :
#7

Sorry, at this point this is outside the realm of things we can help you with as Launchpad support people; we just make build environments available, and don't maintain Ubuntu's Python packages. I suggest asking on askubuntu.com, or filing a bug using "ubuntu-bug python3.8" if you believe it to be a bug in the 20.04 Python packaging.

Can you help with this problem?

Provide an answer of your own, or ask Sampsa Riikonen for more information if necessary.

To post a message you must log in.