8000 C++20 ixx Module | unresolved external symbol _Cnd_timedwait_for · Issue #1080 · libcpr/cpr · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
C++20 ixx Module | unresolved external symbol _Cnd_timedwait_for #1080
Closed
@TheHellTower

Description

@TheHellTower

Description

Whenever I use cpr into my ixx module I just get an LNK2001 unresolved external symbol _Cnd_timedwait_for and can't build my project.

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

When I comment the return lines in sendRequest it compiles.. But I need the response..

Example/How to Reproduce

Create an ixx(C++20) Module with the following code:

export module Req;
import <string>;
import <unordered_map>;
import <cpr/cpr.h>;

namespace Req {
    enum class Method {
        GET,
        POST
    };

    static constexpr const char* baseURL = "https://example.com";

    class Request {
    public:
        Request(Method method, const std::string& endpoint)
            : method_(method), endpoint_(endpoint) {}

        void addHeader(const std::string& key, const std::string& value) {
            headers_[key] = value;
        }

        void addFormData(const std::string& key, const std::string& value) {
            formData_[key] = value;
        }

        cpr::Response sendRequest() const {
            cpr::Url url = cpr::Url{ baseURL + endpoint_ };

            if (method_ == Method::GET) {
                url = addParametersToUrl(url);
                return cpr::Get(url, buildRequestOptions());
            }
            else if (method_ == Method::POST) {
                cpr::Parameters parameters;
                for (const auto& pair : formData_) {
                    parameters.Add({ pair.first, pair.second });
                }
                return cpr::Post(url, buildRequestOptions(), parameters);
            }

            // Default to GET if method is invalid
            return cpr::Get(url, buildRequestOptions());
        }

    private:
        Method method_;
        std::string endpoint_;
        std::unordered_map<std::string, std::string> headers_;
        std::unordered_map<std::string, std::string> formData_;

        cpr::Url addParametersToUrl(const cpr::Url& url) const {
            // Implement parameter handling logic if needed
            return url;
        }

        cpr::Header buildRequestOptions() const {
            cpr::Header options;
            for (const auto& pair : headers_) {
                options.insert({ pair.first, pair.second });
            }
            return options;
        }
    };
}

Possible Fix

No response

Where did you get it from?

vcpkg

Additional Context/Your Environment

  • OS: Windows 10
  • Version: 22H2 Build 19045.4529
    winver_GrXORKyR7S

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0