5

So i have came along with cURL as a very nice library and working very fine in OSX. But on windows now i have got big troubles with getting ready with this library. I googled now for about 2 days and tried over a dozen (in detail) different ways to get this ready. Without any success at all.

Here are some ways I basically tried:

  1. The direct Download: The problem here already starts with the right download. The official download page is pretty confusing, so i considered this "cURL Download Wizard" > "libcurl development" which gives me a version, that i should be able to include into any project. But how exactly to include it? In ANY instructions out there it leads me to directories i dont even have. Almost always this "curllib.lib" is mentioned. I downloaded about 6 different versions on that downloadpage, in none of them there is this file. (See for example this instruction)
  2. Git + CMake: As a solution on the aboves Link there is suggested to use git clone on this. I did all the instructions there and also get the Projects generated with just warnings. But here it says as well:
    After building install target, your will find bin/include/lib folders in C:\curl.vc12
    Well, i did not really get his point of "build install target", i just build the entire project map as it comes. Compiles fine (115 succeeded, 0 failed, 2 skipped). But now C:\curl.vc12 is not there. What do i have to pre-setup before compiling this?
  3. NuGet: The idea comes from the link in point (1) again, a different solution with NuGet.
    With Successfully added 'curl 7.30.0.2' to test. it also seemed nice, but compiling simple.c leads to a bunch of unresolved external symbol linker errors. But a solution is provided:
    Make sure the include directory and lib directory are specified under the Visual C++ directories in project properties.
    So in Project > Properties > VC++ Properties > "Include Directories" and
    Project > Properties > VC++ Properties > "Library Directories"
    as well as in Project > C/C++ > General > "Additional Include Directories" and in Project > Linker > General > "Additional Library Directories" I desperately added the \packages\ path from my project folder.
    As mentioned in the instructions, I added libcurl.lib;libeay32.lib;ssleay32.lib;Ws2_32.lib;libssh2.lib;zlib.lib;wldap32.lib; to Project > Linker > Input > "Additional Dependencies".
    All that done, the unresolved external symbol errors are gone! Therefore I get just one error saying cannot open file 'libcurl.lib'. What can I do here?

I am pretty new to all that. But I am trying really hard now to get this finally to work. So what can I do?
I work with Visual Studio 2013 Community Edition. The currently most recent version of cURL is 7.42.1. Any help is highly welcome!

Community
  • 1
  • 1
beshtaa
  • 53
  • 1
  • 4

2 Answers2

11

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

  1. Then open your project.
  2. Open your project's properties.
  3. Make sure you choose Release as configuration (top left corner)!
  4. Navigate to VC++ Directories > Include directories and add C:\curl-7.42.1\builds\release\include
  5. Add C:\curl-7.42.1\builds\release\lib to VC++ Directories > Library directories.
  6. Go to Linker > Input > Additional Dependencies and add libcurl.lib.
  7. 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.

Jeinzi
  • 153
  • 3
  • 8
  • 1
    With tears in my eyes and a cup of coffee in my hand I can go on, because you Sir made my day. (: Thank you very much! Edit: Please change *Makefile.vs* to *Makefile.vc* – beshtaa May 18 '15 at 08:00
  • Nice to hear, you're welcome! :) Edited my post as you pointed out. – Jeinzi May 18 '15 at 15:05
  • 1
    Also libcurl could be built for Windows using this build script: https://github.com/blackrosezy/build-libcurl-windows – Alexander Rodin Dec 02 '15 at 21:01
  • Not work for me "about viewed 1217 times" 2 accepts ? definitely not works –  Feb 03 '16 at 14:06
  • @delive it does work, but there are some things that you need to be sure you're doing. You need to make sure you're executing/compiling in 'Release' mode and not 'Debug' mode. I was beating my head as well. This gets you 95% of the way there, up to you to get the rest of the way. – TriHard8 Oct 23 '16 at 06:32
  • I've spent two days on this, every states to build static. When I get back ,and this works. Many a man tear go unto you – Jamie Nicholl-Shelley Oct 30 '17 at 18:37
0

I had the same issue. I downloaded the curl from https://github.com/curl/curl. you can actually compile it directly with Visual Studio 2013 (but be careful with parameters setting: x64 with release). The major difference is that it gives you libcurl_imp.lib. Then all you have to do is to set the environment variables as described above. Just want to mention, you will have to use libcurl_imp.lib rather than libcurl.lib in the additional dependencies (I suspect this change is because of the new version of curl).

Evan
  • 1
  • 2