8000 CPR Port | unresolved external symbol `_Cnd_timedwait_for` · Issue #39829 · microsoft/vcpkg · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

CPR Port | unresolved external symbol _Cnd_timedwait_for #39829

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

Open
TheHellTower opened this issue Jul 10, 2024 · 21 comments
Open

CPR Port | unresolved external symbol _Cnd_timedwait_for #39829

TheHellTower opened this issue Jul 10, 2024 · 21 comments
Assignees
Labels
requires:repro The issue is not currently repro-able Stale

Comments

@TheHellTower
Copy link

Describe the bug
Whenever I install the cpr port I can import it but not use it.
See libcpr/cpr#1080
Environment

  • OS: Windows 10
  • Compiler: Not sure I'm using Visual Studio Preview 2022

To Reproduce
Steps to reproduce the behavior:
vcpkg install cpr:x64-windows

  1. Create a Console C++ project
  2. Set it to either C++17 or C++20 (I use C++20)

To make it a very easy reproduce just use the code under, I use ixx modules from C++20 but the this issue happen even in the minimal example.

#include <cpr/cpr.h>
#include <iostream>

int main()
{
    std::cout << "Hello World!\n";
    cpr::Get(cpr::Url{ "https://api.github.com/repos/whoshuu/cpr/contributors" },
        cpr::Authentication{ "user", "pass", cpr::AuthMode::BASIC },
        cpr::Parameters{ {"anon", "true"}, {"key", "value"} });

    return 0;
}

Expected behavior
The program should compile.

Failure logs

Build started at 5:37 PM...
1>------ Build started: Project: CPRTest, Configuration: Release x64 ------
1>Scanning sources for module dependencies...
1>cpr.lib(threadpool.cpp.obj) : error LNK2001: unresolved external symbol _Cnd_timedwait_for
1>CPRTest.exe : fatal error LNK1120: 1 unresolved externals
1>Done building project "CPRTest.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 5:37 PM and took 00.385 seconds ==========

Severity	Code	Description	Project	File	Line	Suppression State	Details
Error	LNK2001	unresolved external symbol _Cnd_timedwait_for	CPRTest	C:\Users\TheHellTower_THT\source\repos\CPRTest\CPRTest\cpr.lib(threadpool.cpp.obj)	1		
Error	LNK1120	1 unresolved externals	CPRTest	C:\Users\TheHellTower_THT\source\repos\CPRTest\x64\Release\CPRTest.exe	1		

Additional context
I opened an issue on the cpr repository here

@WangWeiLin-MV WangWeiLin-MV added the requires:repro The issue is not currently repro-able label Jul 11, 2024
@WangWeiLin-MV
Copy link
Contributor

Using the latest version of vcpkg for local installation does not reproduce the issue.

Could you please try these codes?

command that %your_vcpkg_dir% need modified

cmake -Bbuild_dir -DCMAKE_BUILD_TYPE=Debug -DVCPKG_TARGET_TRIPLET=x64-windows -DCMAKE_TOOLCHAIN_FILE=%your_vcpkg_dir%/scripts/buildsystems/vcpkg.cmake

cmake --build build_dir --config Debug

main.cpp

#include "cpr/cpr.h"

#include <iostream>

int main() {

    std::cout << "cpr" << std::endl;

    cpr::Get(
        cpr::Url{ "https://api.github.com/repos/whoshuu/cpr/contributors" },
        cpr::Authentication{ "user", "pass", cpr::AuthMode::BASIC },
        cpr::Parameters{ {"anon", "true"}, {"key", "value"} }
    );

    cpr::Response response = cpr::Get(cpr::Url{ "https://example.com" });

    std::cout << response.status_code << " " << response.reason << std::endl;

    return 0;
}

CMakeLists.txt

cmake_minimum_required(VERSION 3.25.1)
project(Proj VERSION 0.1.2.3 LANGUAGES CXX)

add_executable(main main.cpp)
target_compile_features(main PRIVATE cxx_std_23)

find_package(cpr CONFIG REQUIRED)
target_link_libraries(main PRIVATE cpr::cpr)

@TheHellTower
Copy link
Author
TheHellTower commented Jul 11, 2024

Using the latest version of vcpkg for local installation does not reproduce the issue.

I'm not using the CMake compiler myself but MSVC one and I never got this issue before it happened after I completelly renewed my vcpkg install.

CPRTest.zip

@BillyONeal
Copy link
Member

_Cnd_timedwait_for comes from the C runtime libraries. It sounds like some parts were built with different versions of MSVC and the linker and standard libraries being used are not newer than the newest used in the link.

@TheHellTower
Copy link
Author

_Cnd_timedwait_for comes from the C runtime libraries. It sounds like some parts were built with different versions of MSVC and the linker and standard libraries being used are not newer than the newest used in the link.

Does this mean anyone installing the lib now would get this issue ? I'm confused because I think I only have the default version of MSVC..

@TheHellTower
Copy link
Author

So I seen on the readme that CPR got a NuGet package and:

NuGet Package: Compile
VCPKG Build: LNK2001 unresolved external symbol _Cnd_timedwait_for

So I think the it can be a VCPKG issue 🤔

@TheHellTower
Copy link
Author

I know nothing about cpr project. However, every time I build any project from source, I run all the unit tests. Have you run cpr unit tests? Some screenshots (Windows 11 x64):

image

image

You are using cmake.

Copy link

This is an automated message. Per our repo policy, stale issues get closed if there has been no activity in the past 28 days. The issue will be automatically closed in 14 days. If you wish to keep this issue open, please add a new comment.

@github-actions github-actions bot added the Stale label Aug 16, 2024
@github-actions githu 8000 b-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 31, 2024
@bamo-volue
Copy link

This is happening for me as well, on a fresh install. Don't have a repro-case though

@Teles1
Copy link
Contributor
Teles1 commented Oct 20, 2024

This is happening to me as well.

@WangWeiLin-MV
Copy link
Contributor

@bamo-volue @Teles1

Could you please try those code #39829 (comment) ?

If it fails, please append error logs.

@Teles1
Copy link
Contributor
Teles1 commented Oct 21, 2024

@bamo-volue @Teles1

Could you please try those code #39829 (comment) ?

If it fails, please append error logs.

I'm not using cmake though. I wish :(

@Teles1
Copy link
Contributor
Teles1 commented Oct 21, 2024

-- I was able to fix this issue by removing literally everything i had installed related to windows sdk, MSVC versions, STL versions, vcpkg while making sure to clear my $PATH as well and then painfully installing everything by hand.

@xyzhieu
Copy link
xyzhieu commented Nov 1, 2024

i had the same problem with cpr 1.11.0 get from vcpkg.

Does anyone have a solution?

@WangWeiLin-MV WangWeiLin-MV reopened this Nov 1, 2024
@xyzhieu
Copy link
xyzhieu commented Nov 1, 2024

I discovered my problem and solved it. I need to install the appropriate Visual C++ Redistributable to run the code in other windows.

@crinai
Copy link
crinai commented Dec 3, 2024

It may be a MSVC bug,It's solved after I upgrade the Visual studio to the latest version(17.12.2)

@WangWeiLin-MV
Copy link
Contributor

i had the same problem with cpr 1.11.0 get from vcpkg.

Could you please help to give some reproduce steps and demo?

@bamo-volue
Copy link

@bamo-volue @Teles1

Could you please try those code #39829 (comment) ?

If it fails, please append error logs.

We changed VM after running into that issue, so it hasn't been an issue since after setting it up on a new system. Sorry for no repro

@ELeeScape
Copy link
8000
ELeeScape commented Dec 3, 2024

I'm also seeing this issue, "error LNK2019: unresolved external symbol _Cnd_timedwait_for", building with MSVC via CMake, using cpr 1.11.0. I'll try to boil it down to a minimal repro. Curiously, my coworker can build the same code on his machine just fine without error, which strongly indicates that the cause is environmental in some way, though our environments appear to be the same at first glance. I'm looking more closely for subtle differences.

[Edit] My coworker has only one version of the MSVC build tools installed, "v143 14.41". I have two different versions installed, "v143 14.38" and "v143 14.41". When I configure my CMake project, vcpkg finds and uses 14.41:

-- Running vcpkg install
Fetching registry information from https://github.com/microsoft/vcpkg (HEAD)...
Detecting compiler hash for triplet x64-windows...
Compiler found: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.41.34120/bin/Hostx64/x64/cl.exe

But when CMake generates the project file for my application, it finds version 14.38:

-- Running vcpkg install - done
-- The CXX compiler identification is MSVC 19.38.33141.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe - skipped

It would make sense that I'd get linker errors trying to link a lib built with one version of the runtime to an app built with a different version of the runtime (I guess?). Not sure how to correctly fix it yet, though. I could just install one of the platform tools versions, of course, but I'd rather make my CMake system more robust in the face of multiple versions. In any case, this is likely not a problem in cpr specifically, except in that it apparently highlights an incompatibility between the two platform versions. Or that's my working theory right now.

Supposedly I should be able to specify the platform tools version with -T v143,version=14.41 on the configure command line, but that seems to make no difference in the behavior described above.

[Edit2] I removed platform tools 14.38, and updated to the latest version of Visual Studio, so now the only version of the platform tools on my machine is 14.42, which both vcpkg and my own project use, and everything is fixed.

@crinai
Copy link
crinai commented Dec 4, 2024 via email

@Binary-System
Copy link

I discovered my problem and solved it. I need to install the appropriate Visual C++ Redistributable to run the code in other windows.

What redistributable exactly did you install to solve it?

@jwpleow
Copy link
jwpleow commented May 28, 2025

This also happened to me.

  • Built libcpr with vcpkg on a VM with Visual Studio 17.14.2
  • Tried to use a machine with Visual Studio 17.11.2 to compile something using the prebuilt libcpr from the VM; encountered the error
  • As per the other comments, the fix was to upgrade the machine to the latest Visual Studio (17.14.2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
requires:repro The issue is not currently repro-able Stale
Projects
None yet
Development

No branches or pull requests

13 participants
0