Не могу подключить к своему Clion проекту на Windows 10
#include <iostream>
#include <curl/curl.h>
int getCurrentMMR(std::string steamId) {
CURL *curl;
CURLcode res;
std::string readBuffer;
curl = curl_easy_init();
if(curl) {
std::string url = "https://api.opendota.com/api/players/" + steamId + "/mmr";
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
json j = json::parse(readBuffer);
return j["solo_competitive_rank"];
}
перепробовал много способов, не получается fatal error: curl/curl.h: No such file or directory
CMakeLists.txt
cmake_minimum_required(VERSION 3.24)
project(Ddd)
find_package(CURL REQUIRED)
include_directories(${CURL_INCLUDE_DIR})
target_link_libraries(Ddd ${CURL_LIBRARIES})
set(CURL_INCLUDE_DIR C:/Users/msham/CLionProjects/Dota/CURL/include)
set(CURL_LIBRARY C:/Users/msham/CLionProjects/Dota/CURL/lib)
INCLUDE_DIRECTORIES(C:/Program Files/11)
add_executable(Ddd main.cpp)
Ответы (2 шт):
Автор решения: Ellenord
→ Ссылка
Открой PowerShell, и туда вбей следующее:
git clone https://github.com/microsoft/vcpkg
cd vcpkg
.\bootstrap-vcpkg.bat
.\vcpkg install curl
.\vcpkg integrate install
После чего тебе выдаст что-то вроде этого:
Applied user-wide integration for this vcpkg root.
CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=C:/Users/ellen/git/vcpkg/scripts/buildsystems/vcpkg.cmake"
All MSBuild C++ projects can now #include any installed libraries. Linking will be handled automatically. Installing new libraries will make them instantly available.
Вот эту строчку (только путь будет другой) -DCMAKE_TOOLCHAIN_FILE=C:/Users/ellen/git/vcpkg/scripts/buildsystems/vcpkg.cmake вбиваешь сюда:
Вот это запиши в CMakeLists.txt:
cmake_minimum_required(VERSION 3.24)
project(Ddd)
set(CMAKE_CXX_STANDARD 17)
find_package(CURL REQUIRED)
add_executable(Ddd main.cpp)
target_link_libraries(Ddd PRIVATE CURL::libcurl)
Автор решения: GihubEnjoyer
→ Ссылка
Решил проблему
cmake_minimum_required(VERSION 3.24)
project(Ddd)
set(CMAKE_CXX_STANDARD 17)
set(CURL_INCLUDE_DIR D:/curl-8.0.1_8-win64-mingw/include)
set(CURL_LIBRARY D:/curl-8.0.1_8-win64-mingw/lib/libcurl.a)
find_package(CURL REQUIRED)
add_executable(Ddd main.cpp)
target_link_libraries(Ddd PRIVATE CURL::libcurl)
