2

In WSL (Ubuntu 24.04), when using Conan to create a package that links pybind11/3.0.1, the resulting executable in the test_package fails to run.

Even if the executable doesn't directly call any pybind11 functions, it links anaconda3/lib/libstdc++.so.6 which seems not to support cpp23.

  • conanfile.py (for package)
# ...
self.requires("pybind11/[*]") # try to use pybind11, if remove this and corresponding commands in CMakeLists.txt, it links the libstdc++.so in 'usr/lib' 
# ...
  • CMakeLists.txt (for package)
# ...
set(CMAKE_CXX_STANDARD 23) # this project uses cpp23
# ...

After removing self.requires("pybind11/[*]") in conanfile.py and corresponding commands in CMakeLists.txt it links the correct (system) libstdc++.so and runs normally.

In a word, without self.requires("pybind11/[*]"), everything runs normal. When trying to use pybind11, it links libstdc++.so under anaconda3/lib which may not supprot cpp23.

Is there any solution for such problem when using cpp23 and pybind11?

  • Error
agtb/0.0.6-1115 (test package): RUN: cmake --build "/home/azusa/file/project/AGTB/test_package/build/gcc-14-x86_64-gnu23-release" -- -j20
[ 50%] Building CXX object CMakeFiles/Adjustment_Traverse.dir/src/Adjustment/Traverse.cpp.o
[100%] Linking CXX executable Adjustment_Traverse
[100%] Built target Adjustment_Traverse


======== Testing the package: Executing test ========
agtb/0.0.6-1115 (test package): Running test()
agtb/0.0.6-1115 (test package): RUN: ./Adjustment_Traverse
./Adjustment_Traverse: /home/azusa/anaconda3/lib/libstdc++.so.6: version `GLIBCXX_3.4.31' not found (required by ./Adjustment_Traverse)

ERROR: agtb/0.0.6-1115 (test package): Error in test() method, line 64
        self.run(cmd) # self.run(cmd, env="conanrun") leads to the same result
        ConanException: Error 1 while executing

As you can see, it succeeds to build but fails to run. I'm pretty sure that the source file never include any pybind11 headers.

New contributor
AzusaYu is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
1
  • The issue isn’t with pybind11 itself, but with which libstdc++ your test executable is picking up at runtime. Because Conan is resolving Python from your Anaconda installation, the linker ends up binding against ~/anaconda3/lib/libstdc++.so.6, which is too old and doesn’t provide GLIBCXX_3.4.31 required by GCC 14 / C++23. Commented 19 hours ago

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.