Getting LibCurl to work with Visual Studio 2013

I'm having trouble getting LibCurl to work with Visual Studio 2013. I downloaded the current version (curl-7.33.0) and tried to follow the instructions I found on this site: Using LibCurl with Visual 2010

But I can not find curllib.lib in the downloaded folder. And I still get errors: enter image description here

After searching the Internet for more help. Now I get these error messages. Does the problem seem to be related to libcurl.lib?

enter image description here

This is what I configured: enter image description here




enter image description here

Inside / lib I have libcurl.lib and libcurl.dll




UPDATE

I downloaded this release for Win32 MSVC: http://curl.haxx.se/download.html#Win32 After adding the libcurl libraries and successfully compiling, I get the following error message:

The application was unable to start correctly (0xc000007b). Click OK to close the application. 

Here is an example of the code I'm trying to run:

 #include <iostream> #include <stdio.h> #include <curl/curl.h> int main(void) { CURL *curl; CURLcode res; curl = curl_easy_init(); if (curl) { curl_easy_setopt(curl, CURLOPT_URL, "http://google.com"); res = curl_easy_perform(curl); /* always cleanup */ curl_easy_cleanup(curl); } return 0; } 



FINAL UPDATE

I believe that LibCurl now works with Visual Studio 2013. Persistence ftw! Although, after spending hours trying to resolve these error messages, I say a little hesitantly that everything is working fine now. That's why I put generosity on this question to get clear and concise instructions on how LibCurl will work with Visual Studio 2013.

This is what I did to make it work:

  • First download the Win32 MSVC package here: http://curl.haxx.se/download.html#Win32 For these instructions, let's say you boot into C: \ LibCurl

  • Launch a new project in Visual Studio. Go to Project | Project Properties | VC ++ Directories | Include Directories | Add the path to the include directory inside the downloaded package. (C: \ libcurl \ include)

  • Then go to Project | Project Properties | Linker | General | Additional Library Directories | Add the path to the lib directory. (Where curllib.dll is located)

  • Then go to Project | Project Properties | Linker | Input | Additional Dependencies | And add curllib.lib

  • Now, if you compile a test program, you will most likely receive a message stating that libsasl.dll is missing. You will need to download this file and place it in the same directory as your assembly. I used 7-Zip to extract libsasl.dll from OpenLDAP for Windows . OpenLDAP for Windows

This is the result of my test code above: enter image description here

+45
c ++ dll visual-c ++ libcurl
Nov 24 '13 at 4:37
source share
11 answers

I would say in the comments, but I do not have enough points. You do not need to copy any DLL files to the program startup directory. Go to Project | Real Estate | Properties of the configuration and in the line Envrionment write: PATH=$(ExecutablePath)$(LocalDebuggerEnvironment) .

From now on, all DLL files from any directory mentioned in Project | Project Properties | VC ++ Directories | Binary should be used without copying.

The rest is exactly the same as you wrote.

+11
Nov 29 '13 at 21:41
source share

Many of these instructions are deprecated because they recommend the win32-ssl-devel-msvc package for curling , which no longer exists .

The following instructions allow you to create libcurl using only :

  • Visual studio 2013
  • curl generic tarball (tested on curl 7.44.0).

A. Creating the libcurl static library

  • Download the latest general video from http://curl.haxx.se/latest.cgi?curl=tar.gz
  • Extract the source to the local directory (we will use C:\libcurl )
  • Open command prompt
  • "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat" To initialize the VC environment variables (configure the VS 2013 installation directory if necessary)
  • cd C:\libcurl\winbuild
  • nmake /f Makefile.vc mode=static VC=12
  • The line should appear in C:\libcurl\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl

B. Link to libcurl in Visual Studio

  • In Visual Studio, right-click your project in Solution Explorer, then click Properties
  • Configuration Properties> C / C ++> General> Additional Directories Include: add C:\libcurl\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\include
  • Configuration Properties> C / C ++> Preprocessor> Preprocessor Definitions: add CURL_STATICLIB
  • Configuration Properties> Connector> General> Additional library directories: add C:\libcurl\builds\libcurl-vc12-x86-release-static-ipv6-sspi-winssl\lib
  • Configuration Properties> Connector> Input> Additional Dependencies: add libcurl_a.lib

C. Invoking libcurl from your project

The following example shows the libcurl call:

 #include "stdafx.h" #include <curl/curl.h> void main(int argc, char* argv[]) { CURL *curl = curl_easy_init(); if (curl) printf("curl_easy_init() succeeded!\n"); else fprintf(stderr, "Error calling curl_easy_init().\n"); } 
+62
Aug 23 '15 at 15:21
source share

The easiest way to do this that I found is to first make sure nuget is installed.

http://www.nuget.org/

Then create your project.

Then go to http://www.nuget.org/packages/curl/ and follow the instructions that should appear in the package manager console and type PM> Install-Package curl

If you then look at the package directory in the project directory, you will find include files and library files. Note that there is a version for Visual Studio 110, not 120, but since libcurl is a C library that you can use with Visual Studio 2013. Make sure the include and lib directories are listed in Visual C ++ directories in the project properties.

Make sure you have the following files in addition to the linker libcurl.lib;libeay32.lib;ssleay32.lib;Ws2_32.lib;libssh2.lib;zlib.lib;wldap32.lib;

+12
Dec 02 '13 at
source share

Another way to use curl / libcurl is to create CMake v2.8.12 + (assuming git is already installed on your computer)

Open the cmd window and change the directory to the appropriate folder

 git clone https://github.com/bagder/curl.git mkdir msbuild cd msbuild cmake ..\curl -G"Visual Studio 12 Win64" -DCMAKE_INSTALL_PREFIX=C:\curl.vc12 -DCURL_STATICLIB=ON < ... lots of output here ... > 

Open the created CURL.sln in Visual Studio and create it.

CMake options that I use in the example

-G selects the build generator. In our case, the 64-bit goal of Visual Studio 2013

-DCMAKE_INSTALL_PREFIX - provides the root folder in which goals should be set

-DCURL_STATICLIB = ON - generates an assembly for a static library

After creating the installation target, your bin / include / lib files will be found in C: \ curl.vc12

Provide a path to your solution and create your code using curl lib.

+9
Dec 03 '13 at 5:18
source share

I tried to do this from scratch with VS2012 (I don't have 2013) and it works fine.

So I'm not sure what the problem is, but:

  • Make sure you download the desired archive.
  • Try putting the cURL folder on a path with no spaces.
  • If you know someone who uses VS2012 or older, try your code with the same include and lib and see if it works.
  • Insert a minimal working example of your code so that I can test it.
+5
Nov 25 '13 at 3:59
source share

This is a bit late, but for those who still have problems, this method worked best for me:

  • Add VS to PATH system:
    For example: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin .
  • Download the current curl-X.zip from http://curl.haxx.se/download.html and unzip it.
  • Open a command prompt in curl-X/winbuild .
  • Call vcvars32.bat .
  • Call nmake /f Makefile.vc mode=static VC=12 .
  • Go to curl-X/builds/libcurl-XXX .

Here you will find inbox and libcurl_a.lib . This library works great for me.
Remember to specify -DCURL_STATICLIB when compiling code using this library.

+4
Feb 21 '15 at 4:08
source share

The problem is that the goals for the standard tools of the VS2013 platform are not set in the NuGet packages . That is why it works in VS2012, but not VS2013. I manually created replacement target files. Instructions and download:

https://github.com/evoskuil/curl-nuget-targets

+2
Mar 11 '14 at 20:55
source share

Download the curl v7.37.0 source code and use the provided Visual Studio project files.

I spent the last few weeks polishing my personal project files, which were based on the VC6 source files and added them to the repository.

.dsw / .dsp (VC6),. sln / .vcproj (VC7, VC7.1, VC8 and VC9, as well as .sln / .vcxproj files (VC10, VC11 and VC12) are provided for both DLL and Static Library Built with support for OpenSSL and Windows SSPI / SChannel in Win32 and x64 configurations.

+2
May 21 '14 at 22:04
source share

I found an easy way to get it working in VC ++ using the latest package. I basically followed the steps in Using libcurl in Visual Studio. Libcurl and VC ++ are very old in the manual.

First, download the ZIP file on the download page https://curl.haxx.se/download.html Email package https://curl.haxx.se/download/curl-7.50.1.zip

Go to projects-> Windows \ VC10 (or your version of VC) \ lib \ libcurl.sln, open the project in VC ++.

Create a project in the DLL release. Debugging DLL does not work on my VC ++.

Go to the assembly \ Win32 \ VC10 \ DLL Release, you can find the lib and dll files created in the previous step.

Create a new folder, including the include and lib folders. Copy libcurb.dll and libcurb.lib everything in the Release DLL folder to the new \ lib. Copy everything in curl-7.50.1 \ include to the new \ include folder.

C ++ Properties β†’ Configuration Properties β†’ VC ++ Directories, add new \ include to include directories, new \ lib in library directories; add new \ lib in Linker β†’ General β†’ Additional libraries, add libcurl.lib in Linker β†’ Input β†’ Additional Dependencies

It seems that I should put the dll file in the same folder with the executable.

It should work.

+2
Aug 24 '16 at 12:51 on
source share

Thanks for the detailed guide!

I saw that the latest version of the msvc libcurl assembly was not available on the official site. So, the library that I found on the Internet is located at the link below.

https://osdn.net/projects/sfnet_jcurltools/downloads/depending/libcurl-7.19.3-win32-ssl-msvc.7z/

+1
Jul 01 '17 at 2:32 on
source share

For Visual Studio 2017, the link steps worked for me. In case the link expires or specifically for those who download the libcurl zip file instead of cloning from GitHub, I will stop the steps here.

  • Set the environment variables with "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 . If the command is successful, you will see a message with the message Environment initialized for 'x64'

  • Download and extract the compressed libcurl file from the libcurl download . I used the .zip file.

  • cd to the winbuild directory inside the extracted libcurl folder.
  • Run nmake /f Makefile.vc mode=dll MACHINE=x64 to build. For more information on build options, see the BUILD.WINDOWS text file in the winbuild folder.
  • Go to one level of the directory and cd to the builds folder to find the compiled files.

All the best!

0
Dec 26 '17 at 15:17
source share



All Articles