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.
~/anaconda3/lib/libstdc++.so.6, which is too old and doesn’t provideGLIBCXX_3.4.31required by GCC 14 / C++23.