curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: http requests

From: Ray Satiro via curl-library <curl-library_at_cool.haxx.se>
Date: Mon, 2 Dec 2019 01:22:01 -0500

On 11/29/2019 10:25 AM, Gustav Wiberg via curl-library wrote:
>
> Im trying to get libcurl working with Visual Studio 2017 with C++ on
> Windows 10. I have tried different things and maybe I have messed VS
> 2017 ;-)
>
> I have never used C++ before so u understand my knowledge about this...
>
>  I want to do a very simple http request and I can't figure out to get
> this to work. Im unsure where to link libraries and what libraries to
> link and what folders to include etc. Should I download from
> https://curl.haxx.se/windows/ ?
>
> Can someone point me in the right direction?

If you are using Visual Studio you will probably have to build it
yourself from source [1] since I don't think we have pre-built libs for
Visual Studio.

There are several ways to build curl using Visual Studio (ie Microsoft's
compiler). Cmake [2], winbuild [3], and project files generated in
common configurations [4].

For example let's look at winbuild. You would open a Visual Studio
command prompt in the platform you want to build, x86 or x64. For
example you probably have at least two of these shortcuts in your Visual
Studio folder (or Tools subfolder) in the start menu:

Visual Studio Command Prompt (this is the x86 one)
run:
cd /d [srcdir]\winbuild
nmake /f Makefile.vc mode=dll VC=15

When done open:

Visual Studio x64 Win64 Command Prompt (this is the x64 one)
run:
cd /d [srcdir]\winbuild
nmake /f Makefile.vc mode=dll VC=15

Then you should have a build of both x86 and x64 libcurl.dll and
curl.exe. If you run dir /b [srcdir]\builds you should see this:

libcurl-vc15-x64-release-dll-ipv6-sspi-winssl
libcurl-vc15-x64-release-dll-ipv6-sspi-winssl-obj-curl
libcurl-vc15-x64-release-dll-ipv6-sspi-winssl-obj-lib
libcurl-vc15-x86-release-dll-ipv6-sspi-winssl
libcurl-vc15-x86-release-dll-ipv6-sspi-winssl-obj-curl
libcurl-vc15-x86-release-dll-ipv6-sspi-winssl-obj-lib

The obj directories are temporary and can be removed, what you really
want are these:

libcurl-vc15-x64-release-dll-ipv6-sspi-winssl
libcurl-vc15-x86-release-dll-ipv6-sspi-winssl

Those contain bin, include and lib.

bin contains curl.exe and libcurl.dll and you would add that location
(x86 and x64 respectively) to your VS project in Debugging >
Environment. For example:

For configurations using x86/Win32 platform add a line:
PATH=[srcdir]\builds\libcurl-vc15-x86-release-dll-ipv6-sspi-winssl\bin;%PATH%

For configurations using x64/Win64 platform add a line:
PATH=[srcdir]\builds\libcurl-vc15-x64-release-dll-ipv6-sspi-winssl\bin;%PATH%

Your application would also need the DLL outside of Visual Studio, so
instead you may want to copy the DLL to the same directory as your
application and then you wouldn't have to specify the PATH that way.

include contains the include files and you would add that location (x86
and x64 respectively) to your VS project in C++ > General > Additional
Include Directories.

lib contains the import file for libcurl.dll, and you would add that
location (x86 and x64 respectively) to your VS project in Linker >
General > Additional Library Directories. Also you would add
libcurl.lib; in Linker > Input > Additional Dependencies.

You can try example docs/examples/simple.c [5] in your project to see if
it's working.

[1]: https://curl.haxx.se/download.html
[2]:
https://raw.githubusercontent.com/curl/curl/curl-7_67_0/docs/INSTALL.cmake
[3]:
https://raw.githubusercontent.com/curl/curl/curl-7_67_0/winbuild/BUILD.WINDOWS.txt
[4]: https://raw.githubusercontent.com/curl/curl/curl-7_67_0/projects/README
[5]:
https://raw.githubusercontent.com/curl/curl/curl-7_67_0/docs/examples/simple.c

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2019-12-02