1

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)
Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
  • You have added the libraries to link with in the *directories* to search for libraries. You must tell MSVC to *link* with the libraries instead. – Some programmer dude Jun 14 '18 at 08:28
  • Could you provide some guide line? Because right now I have no idea how to link the libraries. – Harvey Cordeiro Jun 14 '18 at 08:29
  • I tried adding `libcurl_imp.lib` to Linker > Input > `Additional Dependencies` but still got the same error :-\ – Harvey Cordeiro Jun 14 '18 at 08:40
  • I followed instruction from [this](https://stackoverflow.com/questions/20171165/getting-libcurl-to-work-with-visual-studio-2013) post from user mtlynch (second answer), and now instead of just 1 linker error, I've got like 63 errors of linker errors. There are now 2 types of errors, first unresolved external symbol, and `error LNK2005: _strtoll already defined in LIBCMTD.lib(strtoq.obj)`. :-P – Harvey Cordeiro Jun 14 '18 at 09:29

1 Answers1

0

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.

seccpur
  • 4,996
  • 2
  • 13
  • 21
  • In prerequisite it said `Visual Studio 2017 or Visual Studio 2015 Update 3`. Is it possible to install VS 2017 and use vcpkg on VS 2013? – Harvey Cordeiro Jun 14 '18 at 09:12
  • @HarveyCordeiro: No, Use VS2017. THe compiler will also be used during cross compiling. – seccpur Jun 14 '18 at 15:20