Skip to content

[BUG] cmake lead to missng symbols when linking against pybind11::embed while preloading python with find_package(Python3) #2664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jbigot opened this issue Nov 15, 2020 · 2 comments · Fixed by #2662

Comments

@jbigot
Copy link

jbigot commented Nov 15, 2020

Pre-loading python3 in cmake leads to the target not being linked against python library.

find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
find_package(pybind11 2.3.0 REQUIRED)
add_library(my_target [...])
target_link_libraries(my_target pybind11::embed)

I believe this is due to the following line linking against Python3::Python3 in that case instead of Python3::Pythonprovided by the cmake module

if(TARGET ${_Python}::${_Python})

PROPERTY INTERFACE_LINK_LIBRARIES ${_Python}::${_Python})

@jbigot jbigot changed the title cmake lead to missng symbols when linking against pybind11::embed while preloading python with find_package(Python3) [BUG] cmake lead to missng symbols when linking against pybind11::embed while preloading python with find_package(Python3) Nov 15, 2020
@knarfS
Copy link
Contributor

knarfS commented Nov 15, 2020

I just opened PR #2662 which should fix that bug.

jbigot added a commit to jbigot/pybind11 that referenced this issue Nov 15, 2020
…ct python lib

* with find_package(Python3) it would link the wrong Python3::Pyhton3 instead of the correct Python3::Pyhton
* with find_package(Python2) it would link the wrong Python2::Pyhton2 instead of the correct Python3::Pyhton

Fix pybind#2664
@jbigot
Copy link
Author

jbigot commented Nov 15, 2020

@knarfS you were faster than me, I opened #2665 later than you it seems 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants