Vcpkg: boost_python debug links to python3 release

Created on 8 Jan 2019  路  5Comments  路  Source: microsoft/vcpkg

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:
https://github.com/Microsoft/vcpkg/pull/1453/commits/d88f53de9c284cfc67ba21707d60a44ba41ede8a

port-bug

Most helpful comment

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.)

All 5 comments

With boost 1.69 from
https://github.com/Microsoft/vcpkg/pull/5059
still boost_python36-vc141-mt-gd-x64-1_69.dll (debug) has a dependency on python36.dll (release)

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.

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.)

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.

@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()
Was this page helpful?
0 / 5 - 0 ratings

Related issues

oahzuw picture oahzuw  路  3Comments

tzbo picture tzbo  路  3Comments

madkoala picture madkoala  路  3Comments

cjvaijo picture cjvaijo  路  3Comments

LilyWangL picture LilyWangL  路  3Comments