Getting LibCurl to work with Visual Studio 2013
I would say that in a comment, but I am lacking in points.
You don't have to copy any .dll into your program run catalog.
Go to Project | Properties | Configuration Properties and in line Envrionment write: PATH=$(ExecutablePath)$(LocalDebuggerEnvironment)
.
From now on, all .dlls from any catalog you mention in Project|Project Properties|VC++ Directories|Binary should be usable without copying them.
The rest is exactly as you written.
cURL with Visual Studio 2013
Had problems myself, finally got it working now.
I downloaded curl-7.42.1.zip from the official website.
Within the archive you'll find the source code and winbuild/BUILD.WINDOWS.txt, which basically contains the instructions I followed. I'll assume that it has been unzipped to C:\curl-7.42.1.
Open the Visual Studio command prompt located at
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts
This automatically sets the environment variables needed to use Visual Studio tools like the compiler. Then move to the winbuild directory and call
nmake /f Makefile.vc mode=dll
as described in the text file I mentioned above.
That will create the directory
C:\curl-7.42.1\builds\libcurl-vc-x86-release-dll-ipv6-sspi-winssl
containing libcurl.dll, libcurl.lib and the necessary header files. Let's rename it to C:\curl-7.42.1\builds\release
:'D
- Then open your project.
- Open your project's properties.
- Make sure you choose Release as configuration (top left corner)!
- Navigate to
VC++ Directories > Include directories
and addC:\curl-7.42.1\builds\release\include
- Add
C:\curl-7.42.1\builds\release\lib
toVC++ Directories > Library directories
. - Go to
Linker > Input > Additional Dependencies
and addlibcurl.lib
. - Finally copy
C:\curl-7.42.1\builds\release\bin\libcurl.dll
to your project folder.
That should do the trick! :D If you want to use cURL in debug mode, you can do almost the same, recompile using nmake /f Makefile.vc mode=dll debug=yes
, go to your project's properties, add the newly created directory paths (changing libcurl.lib to libcurl_debug.lib) and you should be done.
Adding CURL Library To Visual Studio 2013
After creating a project and downloading libcurl
you'll want to extract the contents of the libcurl
zip. Afterwards in MVS open your project and look for the solution explorer. Right click on your project and chose Properties
at the bottom.
Under Configuration Properties
-> Linker
-> General
add the folder lib\Release
from where you extracted libcurl
: libcurl-7.19.3-win32-ssl-msvc\lib\Release
in the Additional Library Directories
list.
Under Configuration Properties
-> Linker
-> Input
add curllib.lib
in the Additional Dependencies
list.
Under Configuration Properties
-> C/C++
-> General
add include\curl
from where you extracted libcurl
: libcurl-7.19.3-win32-ssl-msvc\include\curl
in the Additional Include Directories
list.
Press Ok
and you're done. You might even want to take a look at the libcurl
examples here.
LibCurl in Visual Studio 2013 Static Linker Errors Even After Including Necessary Dependencies
First of all, thank you to user Pawan who edited my post; it was my first post and he helped make it up to standards aesthetically with the community so I know what to do in the future.
Anyway, I think I solved my problem. It's probably a bit of an edge case, but it worked for me anyway.
After a while, I decided to build libcurl for Win64 using Visual Studio. To do this, I grabbed the code from this helpful repository:
https://github.com/bagder/curl
I cloned it, and navigated to that directory. I then ran the following commands (this is in Powershell so I used unix-esque commands, but I did not use MinGW for this):
mkdir build
cd build
cmake .. -G "Visual Studio 12 2013 Win64"
This built a Visual Studio Solution that I could open in Visual Studio 2013. In Visual Studio, I went to
Project Properties -> C/C++ -> Code Generation
And switched the Runtime Library
option to "Multi-threaded (/MT)"
Then I built the project, which outputted the following files in the following path:
path_to_pulled_code\build\lib\Release\libcurl.dll
path_to_pulled_code\build\lib\Release\libcurl_imp.exp
path_to_pulled_code\build\lib\Release\libcurl_imp.lib
So, now I had the lib file I needed. Now, in:
Project Properties -> Linker -> Input
I put "libcurl_imp.lib"
and "ws2_32.lib"
under Additional Dependencies
.
As I've said before, I made sure that I had "CURL_STATICLIB"
in Preprocessor Definitions
. I also switched Runtime Library
to "Multi-threaded (/MT)"
for this project.
After all that, well, it compiled! For some reason I needed to copy libcurl.dll
that the aforementioned Visual Studio build of bagder's repo made into my executable path in order for the solution to actually work. But it seems to be working now at least!
Thanks guys. Hopefully this answer will help anyone else who stumbles onto this problem like I did.
Using libcurl from NuGet in C++ (VS2013)
The OpenSSL NuGet package is currently dated June 12, 2013. The targets files for both openssl.1.0.1.24
and openssl.redist.1.0.1.24
contain the following condition:
$(PlatformToolset.ToLower().IndexOf('v110')) > -1
These preclude compilation and linking because VS2013 sets PlatformToolset = v120
by default. The targets will have to be updated for v120
(and for CTP_Nov2013
).
More here on compatibility between RTM and CTP compilers.
Related Topics
How Can My C/C++ Application Determine If the Root User Is Executing the Command
How to Write on a Virtual Webcam in Linux
In C++, What Is a "Namespace Alias"
Overriding a Base's Overloaded Function in C++
System("Command") Produces an Error; But It Works When Invoked Directly from Bash Prompt
Why Is Nonblocking Socket Writable Before Connect() or Accept()
How to Measure CPU Time of a Specific Set of Threads
Why Is Padding Added for Multiple Data Members of Structures and Not for Single Members
About the Binary Compatibility of Linux
Single Process Maximum Possible Memory in X64 Linux
Create Window Without Title Bar
Getting Mangled Name from Demangled Name
Read Unicode Utf-8 File into Wstring
Why Does the Free() Function Not Return Memory to the Operating System
Are There Any Way to Link My Program with Wine-Compiled Part