I am just starting out in c++ and cannot figure out how to add libraries, in particular libcurl. I tried a bunch of tutorials but most were for 2013/10 or didn't work. Can anyone please explain (Preferably in standard/non technical English) how I can add the library? I have already tried adding it in the include section of the program and in the additional dependencies menu.
Note this is a re-post I asked virtually the same question around 3 days ago to which I received no replies. Not sure if that is because its very easy and I should have figured it out my self, or if it just got buried in a flood of questions, or some other reason. In any case sorry for the re-post.
Here's how I've got curl to work with Visual Studio 2017 15.9.14:
C:\curl\
)Developer Command Prompt for VS 2017
(see Windows Start menu or %PROGRAMDATA%\Microsoft\Windows\Start Menu\Programs\Visual Studio 2017\Visual Studio Tools\
) and cd
to C:\curl\winbuild\
nmake /f Makefile.vc mode=static
. This will build curl as a static library into C:\curl\builds\libcurl-vc-x86-release-static-ipv6-sspi-winssl\
Windows Console Application
)Properties -> VC++ Directories -> Include Directories
add C:\curl\builds\libcurl-vc-x86-release-static-ipv6-sspi-winssl\include\
Properties -> VC++ Directories -> Library Directories
add C:\curl\builds\libcurl-vc-x86-release-static-ipv6-sspi-winssl\lib\
thereProperties -> Linker -> Input -> Additional Dependencies
add libcurl_a.lib
, Ws2_32.lib
, Crypt32.lib
, Wldap32.lib
and Normaliz.lib
#define CURL_STATICLIB
#include <curl\curl.h>
int main()
{
CURL *curl;
curl = curl_easy_init();
curl_easy_cleanup(curl);
return 0;
}
Alternatively you can use vcpkg to install curl:
Developer Command Prompt for VS 2017
(see Windows Start menu or %PROGRAMDATA%\Microsoft\Windows\Start Menu\Programs\Visual Studio 2017\Visual Studio Tools\
) and cd
to C:\vcpkg\
bootstrap-vcpkg.bat
vcpkg.exe integrate install
vcpkg.exe install curl