#1003138 libboost-tools-dev: Conflicts between libboost-tools-dev and libboost-python-dev

Package:
libboost-tools-dev
Source:
boost-defaults
Description:
Boost C++ Libraries development tools (default version)
Submitter:
Yousen Zhang
Date:
2022-01-09 06:39:02 UTC
Severity:
normal
#1003138#5
Date:
2022-01-04 19:10:12 UTC
From:
To:
Dear Maintainer,

I tried to compile a simple tutorial following the link [1].

I tried to run

bjam under example/tutorial after prepending the following to Jamroot file:

  using python : 3.9
               : /usr/bin/python3
               : /usr/include/python3.9
               : /usr/lib/python3.9/config-3.9-x86_64-linux-gnu
               ;

However, it always encounter

  /usr/bin/ld: cannot find -lboost_python
  collect2: error: ld returned 1 exit status

      "g++"    -o "hello_ext.cpython-39-x86_64-linux-gnu.so" -Wl,-h -Wl,
hello_ext.cpython-39-x86_64-linux-gnu.so -shared -Wl,--start-group
"hello.o"  -Wl,-Bstatic  -Wl,-Bdynamic -lboost_python -ldl -lpthread -lutil
-Wl,--end-group -fPIC -g

I tried to manually compile, replace boost_python with boost_python39,
through
       g++     -o "hello_ext.cpython-39-x86_64-linux-gnu.so" -Wl,-h -Wl,
hello_ext.cpython-39-x86_64-linux-gnu.so -shared -Wl,--start-group
"hello.o"  -Wl,-Bstatic  -Wl,-Bdynamic -lboost_python39 -ldl -lpthread
-lutil -Wl,--end-group -fPIC -g

It succeeds.

I was wondering if this is from the conflicts between the building tools
and libraries for boost-python. I am a novice and please correct me if I am
wrong.

I worked on WSL2-Debian Stable. And I installed build-essential,
python3-dev, libboost-python-dev, and libboost-tools-dev.

Library versions via apt search are:
    libboost-python-dev/stable,now 1.74.0.3 amd64
    libboost-tools-dev/stable,now 1.74.0.3 amd64
    python3-dev/stable,now 3.9.2-3 amd64
    build-essential/stable,now 12.9 amd64

Best regards,

Yousen

[1] https://github.com/boostorg/python/tree/develop/example/tutorial

#1003138#10
Date:
2022-01-09 06:34:35 UTC
From:
To:
A related/similar post on Windows is
https://stackoverflow.com/questions/44153858/linking-against-boost-python-3-6-cant-find-boost-python-instead-of-boost-pytho

As I had set using python 3.9, but ld will always tried to link
libboost_python instead of libboost_python3.9

I also checked the header  /usr/include/boost/python/detail/config.hpp
It shows
#define BOOST_LIB_NAME BOOST_PYTHON_CONCAT(boost_python, PY_MAJOR_VERSION,
PY_MINOR_VERSION)

I suspect this package won't work properly out the PY_MAJOR_VERSION and
PY_MINOR_VERSION defined in /usr/include/python3.9/Python.h