简体   繁体   中英

How to setup libcurl on visual studio

I am using windows 10, and using Visual Studio 2013 (because I have some library dependencies). I want to use libcurl to make HTTP request to my local server. So I download library from here which is version 7.6.0.

I downloaded and install MinGW and CMake and followed this instruction. After that I am completely lost on how to Add this library to my project.

So I added

"..\curl-7.60.0\include"
"..\curlpp-0.8.1\include"

to my project's C/C++ > Additional Include Directories and I also added

"..\curl-7.60.0\build\lib\libcurl_imp.lib"
"..\curl-7.60.0\lib"
"..\curl-7.60.0\build\lib\libcurl.dll"
"..\curl-7.60.0\build\lib"
"..\curl-7.60.0\build\src"
"..\curlpp-0.8.1\build\CMakeFiles\curlpp_static.dir\src"

to my project's Linkers > Additional Directories Libraries

But when I added these code to my project and run it. I've got a linker error. Please help, I have no idea how to add the dependencies :-P

code:

#include <curl/curl.h>
...
void AppMain::setup() {
    ...
    long flags = CURL_GLOBAL_ALL;
    CURLcode curlcode = curl_global_init(flags ); 
    return 0;
}

error:

Error 5 error LNK2019: unresolved external symbol _curl_global_init referenced in function "public: void __thiscall AppMain::setup(void)" (?setup@AppMain@@QAEXXZ)

Install vcpkg ( MS packager to install windows based open source projects) and use powershell command like so .\\vcpkg install libcurl:x64-windows-static . Dependency libraries will be auto installed for you. The libcurl library can be auto integrated to your VS project using .\\vcpkg integrate install .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM