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

[poco] MTd link failure #38462

Open
az-faro opened this issue Apr 29, 2024 · 7 comments
Open

[poco] MTd link failure #38462

az-faro opened this issue Apr 29, 2024 · 7 comments
Assignees
Labels
category:port-bug The issue is with a library, which is something the port should already support

Comments

@az-faro
Copy link

az-faro commented Apr 29, 2024

Describe the bug
I use the poco library via vcpkg. The application uses /MTd runtime library, but vcpkg is set to not use static libraries. Poco builds correctly, but in the linking stage I get LINK : fatal error LNK1104: cannot open file 'PocoFoundationmtd.lib'.

Environment

  • OS: Windows 10
  • Compiler: Microsoft Visual C++ 2019, version 16.11.15

To Reproduce
Steps to reproduce the behavior:

  1. Add {"name":"poco", "platform": "x64|windows"} to vcpkg.json.
  2. Create Visual Studio C++ project with vcpkg activated that uses some Poco functionality (for example #include "Poco/URI.h").
  3. The vcpkg config in the project is the default apart from Use Vcpkg Manifest that is set to Yes. Particularly Use Static Libraries is set to No, but this should be the default.
  4. Build project in debug config with Runtime Library set to Multi-threaded Debug (/MTd)

Expected behavior
I would expect the project to link correctly and give me access to Poco functionality.

Failure logs

1>------ Build started: Project: PocoTest, Configuration: Debug x64 ------
1>LINK : fatal error LNK1104: cannot open file 'PocoFoundationmtd.lib'
1>Done building project "PocoTest.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Additional context

  • I could get the linking to work correctly by adding $(VcpkgManifestRoot)\vcpkg_installed\x64-windows-static\x64-windows-static\debug\lib to the Linker -> General -> Additoinal LIbrary Directories setting, but this shouldn't be needed. And I'm not even sure this is the correct linking.
  • The PocoFoundatinmtd.lib is correctly built, it's just the linking that is incorrect. However I suspect the linking path is probably correct and the error is trying to link to the mtd variant of the library when it should be just the d variant.
  • Note that this particular configuration of /MTd + vcpkg as dll links just fine with other libraries such as nlohmann-json and miniz.
@FrankXie05 FrankXie05 added the category:port-bug The issue is with a library, which is something the port should already support label Apr 30, 2024
@FrankXie05
Copy link
Contributor

@az-faro Thanks for posting this issue, I think we have included the debug path correctly, can you rerun the command ./vcpkg integrate install and try again?

<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);$(_ZVcpkgCurrentInstalledDir)$(_ZVcpkgConfigSubdir)lib;$(_ZVcpkgCurrentInstalledDir)$(_ZVcpkgConfigSubdir)lib\manual-link</AdditionalLibraryDirectories>

@az-faro
Copy link
Author

az-faro commented May 20, 2024

Hello @FrankXie05. This indeed now works correctly in debug.

The same issue persists in release though. I know I didn't mention that in the original bug report, but it's exactly the same issue in release as there is in debug.

@az-faro
Copy link
Author

az-faro commented May 20, 2024

Actually, upon closer inspection this still doesn't work for me. Using the latest version of vcpkg and poco 1.13.3 still shows exactly the same issue:

Build started...
1>------ Build started: Project: PocoTest, Configuration: Debug x64 ------
1>Installing vcpkg dependencies to C:\work\unversioned\PocoTest\vcpkg_installed\x64-windows
1>"C:\work\vcpkg\vcpkg\vcpkg.exe" install --x-wait-for-lock --triplet "x64-windows" --vcpkg-root "C:\work\vcpkg\vcpkg\" "--x-manifest-root=C:\work\unversioned\PocoTest\" "--x-install-root=C:\work\unversioned\PocoTest\vcpkg_installed\x64-windows\"
1>Detecting compiler hash for triplet x64-windows...
1>Compiler found: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe
1>The following packages will be built and installed:
1> * expat:[email protected]
1> * pcre2[core,jit,platform-default-features]:[email protected]
1> poco:[email protected]
1> * vcpkg-cmake:x64-windows@2024-04-18
1> * vcpkg-cmake-config:x64-windows@2022-02-06#1
1> * zlib:[email protected]
1>Additional packages (*) will be modified to complete this operation.
1>Restored 6 package(s) from C:\Users\ZettersA\AppData\Local\vcpkg\archives in 5.1 s. Use --debug to see more details.
1>Installing 1/6 vcpkg-cmake:x64-windows@2024-04-18...
1>Elapsed time to handle vcpkg-cmake:x64-windows: 37 ms
1>vcpkg-cmake:x64-windows package ABI: 8b42a42ed1bdf897a526265f62c948a0025fbd3832eec15b9a644732e1bb56a2
1>Installing 2/6 zlib:[email protected]...
1>Elapsed time to handle zlib:x64-windows: 34.9 ms
1>zlib:x64-windows package ABI: 3ea500905e5b64da0a81e1616c29e8ecb067f2cfd89cceaedb122747f77d9a4d
1>Installing 3/6 vcpkg-cmake-config:x64-windows@2022-02-06#1...
1>Elapsed time to handle vcpkg-cmake-config:x64-windows: 16.7 ms
1>vcpkg-cmake-config:x64-windows package ABI: f2b3d24fa2b61fe3ca168cfb265f3c64a3cf82219fbeac798ca0317c7303e895
1>Installing 4/6 pcre2[core,jit,platform-default-features]:[email protected]...
1>Elapsed time to handle pcre2:x64-windows: 68.4 ms
1>pcre2:x64-windows package ABI: f029c303a48d9a6057ef886c81d05aec6e03b71e896d43090ba461a1d05dc104
1>Installing 5/6 expat:[email protected]...
1>Elapsed time to handle expat:x64-windows: 38.3 ms
1>expat:x64-windows package ABI: 92b9ffebe49c1fb841b90332f61195f5135143ff108dc6dc900e0bca216ee815
1>Installing 6/6 poco:[email protected]...
1>Elapsed time to handle poco:x64-windows: 886 ms
1>poco:x64-windows package ABI: a60bfe72fb139c264257e556727ee7396625f9a26a9e01bc5ffdfce931bb81e7
1>Total install time: 1.1 s
1>The package poco is compatible with built-in CMake targets:
1>
1> find_package(Poco REQUIRED [COMPONENTS ...])
1> target_link_libraries(main PRIVATE Poco::)
1>
1>PocoTest.cpp
1>LINK : fatal error LNK1104: cannot open file 'PocoFoundationmtd.lib'
1>Done building project "PocoTest.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

@dg0yt
Copy link
Contributor

dg0yt commented May 20, 2024

  1. Add {"name":"poco", "platform": "x64|windows"} to vcpkg.json.

Note that this request to install poco when you build "for x64 or for windows".
It does not set what type of lib to build. You have to set the vcpkg target triplet for that choice.

The PocoFoundatinmtd.lib is correctly built, it's just the linking that is incorrect.

Are you sure? The log says

1>Installing 6/6 poco:[email protected]...

And that package builds (CI logs):

poco:x64-windows:/debug/lib/PocoFoundationd.lib
poco:x64-windows:/lib/PocoFoundation.lib

@az-faro
Copy link
Author

az-faro commented May 20, 2024

  1. Add {"name":"poco", "platform": "x64|windows"} to vcpkg.json.

Note that this request to install poco when you build "for x64 or for windows". It does not set what type of lib to build. You have to set the vcpkg target triplet for that choice.

As far as I understand Visual Studio will decide which triplet to use depending on which configuration I choose to build and if I configure that I want to use static libraries or not.

The PocoFoundatinmtd.lib is correctly built, it's just the linking that is incorrect.

Are you sure? The log says

1>Installing 6/6 poco:[email protected]...

And that package builds (CI logs):

poco:x64-windows:/debug/lib/PocoFoundationd.lib poco:x64-windows:/lib/PocoFoundation.lib

Well that's the issue then isn't it? if it builds those version and then tries to link the mtd version? I don't choose which version to link, vcpkg does.

@dg0yt
Copy link
Contributor

dg0yt commented May 20, 2024

I don't choose which version to link, vcpkg does.

Does it? I assume you use msbuild, not CMake. Vcpkg uses "autolinking" for msbuild. It would choose exactly (all!) the files which are there.
However, if a source or header has a #pragma comment(lib PocoFoundatinmtd), the linker wants to have that lib, too. If such a header is installed by vcpkg, it is a bug. But quite often users find such lines in own code or non-vcpkg dependencies.

@az-faro
Copy link
Author

az-faro commented May 20, 2024

Well this is exactly all the code in the test project I made to illustrate the issue. I think it's safe to say I'm not forcing PocoFoundationmtd to load.

#include <iostream>
#include "Poco/URI.h"

int main()
{
    std::cout << "Hello World!\n";
}

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

3 participants