Skip to content
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

boost_python debug links to python3 release #5097

Closed
ulrichard opened this issue Jan 8, 2019 · 11 comments
Closed

boost_python debug links to python3 release #5097

ulrichard opened this issue Jan 8, 2019 · 11 comments
Assignees
Labels
category:port-bug The issue is with a library, which is something the port should already support

Comments

@ulrichard
Copy link

I am in the process of using some more libraries from vcpkg, namely python and boost. Release builds are mostly working, but when launching the debug build, the python environment is not properly initialized. I suspect that it is related to the fact that boost_python36-vc141-mt-gd-x64-1_68.dll (debug) has a dependency on python36.dll (release), and that I didn't find an option to specify "python-debugging=on" in the boost port.
Apparently this issue was fixed once in the past:
d88f53d

@ulrichard
Copy link
Author

With boost 1.69 from
#5059
still boost_python36-vc141-mt-gd-x64-1_69.dll (debug) has a dependency on python36.dll (release)

@ulrichard
Copy link
Author

Maybe there are cases where it is ok to link a release dll from a debug build as long as it has a pure C ABI. But we also link directly to the python lib as found by the cmake built in finder script. This is the debug version of the python lib for debug builds. Now this combination for sure wrecks havoc. So we definitely must be able to instruct boost to link against the debug python lib.

@perrog
Copy link

perrog commented Jan 13, 2019

I have the same problem. But I'm also struggling to understand how link.exe can depend on python36_d.lib when it is nowhere explicitly referenced.

pyconfig.h properly imports pragma comment ( lib: python36.lib ) indirectly via include boost/python.h. There is one place in vcpkg.targets which adds "$(VcpkgRoot)debug\lib*.lib" to AdditionalDependencies, probably this make link.exe try all .libs and take the most appropriate one. Have command-line arguments higher precedence than source code pragma commen (lib) in link.exe? Does link.exe really work as expected here? Anyway, giving link.exe a help to find python36.lib solves the problem, and I set this in my local project.
%(AdditionalLibraryDirectories);$(VcpkgRoot)lib
%(AdditionalDependencies);python36.lib

(I would expect AdditionalLibraryDirectories should be enough, since the source code reference python36.lib, but stating python36.lib again in AdditionalDependencies also required.)

@PhoebeHui PhoebeHui added the category:port-feature The issue is with a library, which is requesting new capabilities that didn’t exist label Jan 16, 2019
@Cheney-W Cheney-W added category:port-bug The issue is with a library, which is something the port should already support and removed category:port-feature The issue is with a library, which is requesting new capabilities that didn’t exist labels Jul 8, 2019
@xobs
Copy link

xobs commented Aug 15, 2019

This might be the cause of issues that I'm seeing when attempting to link against boost-python for x64-windows-static, where the process silently exits with return code 0xc0000409.

@Shatur
Copy link
Contributor

Shatur commented Oct 30, 2020

@perrog, yes, this is the root of the issue.
Temporary workaround for target that links with Boost.Python:

if(VCPKG_TOOLCHAIN)
    target_link_directories(${PROJECT_NAME} PRIVATE ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib;${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib)
endif()

@frivard-coveo
Copy link
Contributor

I also have the same problem.
My application has a link library to both Python3 and boost-python.
The port Python3 builds python39_d.lib.
But the port boost-python produces boost_python39-vc142-mt-gd-x64-1_74.dll which depends on python39.dll (release).
After a full build, the build output directory contains python39_d.dll, because I specified that I link Python3 (this is ok), but my application can't start because it is missing python39.dll, from the transitive dependency on boost-python.

@PhoebeHui
Copy link
Contributor

@PhoebeHui PhoebeHui reopened this Dec 29, 2021
@PhoebeHui
Copy link
Contributor

The fix doesn't work, it still depends on python310.dll.

image

@yurybura
Copy link
Contributor

yurybura commented Dec 29, 2021

@PhoebeHui Have you defined BOOST_DEBUG_PYTHON before build?
Ref:

if(CMAKE_CXX_FLAGS_DEBUG MATCHES "BOOST_DEBUG_PYTHON" AND CMAKE_BUILD_TYPE STREQUAL "Debug")
list(APPEND B2_OPTIONS
python-debugging=on
)
endif()

@PhoebeHui
Copy link
Contributor

@yurybura, thank you! I forget that, after I define BOOST_DEBUG_PYTHON, it links to python3 debug libs.

image

@Bardo91
Copy link

Bardo91 commented Mar 31, 2022

@yurybura, thank you! I forget that, after I define BOOST_DEBUG_PYTHON, it links to python3 debug libs.

image

I am stuck with the same problem. Where did you need to set it exactly?

I tried in the CMakeLists of my project, and in the cached variables of the CMakePresets but neither of them worked. It still asks me for the Release libraries.

I found this issue #23374 , and I understood that what I need is to modify boost compilation. Is that right? and how should I do it then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:port-bug The issue is with a library, which is something the port should already support
Projects
None yet
Development

No branches or pull requests

10 participants