Skip to content

pybind11 links against wrong Python library when PYBIND11_FINDPYTHON is present #23052

Description

@SunBlack

Describe the bug

In case you are using pybind11 with PYBIND11_FINDPYTHON, the debug build is failing with LINK : fatal error LNK1104: cannot open file 'python310.lib'.

Environment

  • OS: Windows
  • Compiler: MSVC 2022

To Reproduce
Steps to reproduce the behavior:

  1. ./vcpkg install pybind11
  2. Using following code:

CMakeLists.txt

cmake_minimum_required(VERSION 3.14...3.22)
project(test)

set(PYBIND11_FINDPYTHON ON)
find_package(pybind11 2.6 CONFIG REQUIRED)

add_executable(${PROJECT_NAME}
	main.cpp
)

target_link_libraries(${PROJECT_NAME}
	PRIVATE
		pybind11::embed
)

main.cpp

#include <pybind11/embed.h>

int main(int argc, char** argv)
{
	pybind11::scoped_interpreter guard{};
	return 0;
}

Expected behavior

Linker should succeed.

Additional context

  Without vcpkg With vcpkg
With PYBIND11_FINDPYTHON Build succeeded cannot open file 'python310.lib'
Without PYBIND11_FINDPYTHON Build succeeded Build succeeded

As the debug build works when not using vcpkg even when PYBIND11_FINDPYTHON is ON it looks like an vcpkg issue for me

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Stalecategory:port-bugThe issue is with a library, which is something the port should already support

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions