Saturday, June 22, 2013

How to build cURL static library with SSL support on Windows

This is a short note about building cURL with SSL support on Windows.

Tools required:
  1. cURL source: Download latest cURL source from here.
  2. Microsoft Visual C++ 2008 or 2010 Express Edition: It looks like 2008 Express Edition is no longer available, but 2010 Express Edition can be downloaded from here.
  3. Win32 OpenSSL:
    1. Download Win32 OpenSSL installer and Visual Studio redistributable from here - these are Win32 OpenSSL v1.0.1e and Visual C++ 2008 Redistributables at the time of this writing.
    2. Install Win32 OpenSSL; by default it installs to C:\OpenSSL-Win32.
    3. Install Visual C++ 2008 redistributable.

Building cURL:
  1. Run Visual Studio 2008 Command Prompt from Start Menu > All Programs > Microsoft Visual C++ 2008 Express Edition > Visual Studio Tools. Or, Visual Studio 2010 Command Prompt if you're using Visual C++ 2010.
  2. Navigate to winbuild sub-directory in cURL source directory, and issue following command:
nmake /f Makefile.vc mode=static WITH_SSL=static WITH_DEVEL=C:\OpenSSL-Win32 VC=X ENABLE_SSPI=no ENABLE_IDN=no ENABLE_WINSSL=no DEBUG=no MACHINE=x86 GEN_PDB=no ENABLE_IPV6=yes

Note: In VC=X, replace X with 9 for Visual C++ 2008 or 10 for Visual C++ 2010.

Once build is complete, cURL static libraries would be copied to builds sub-directory in cURL source directory.

8 Comments:

Anonymous Anonymous said...

I'm using Visual Studios 2012. How do I do this in VS2012? 'Navigate to winbuild sub-directory in cURL source directory' I don't have such thing like a winbuild directory.

4:29 PM  
Anonymous Anonymous said...

Did you download cURL from here:
http://curl.haxx.se/download.html

Download curl-7.33.0.tar.gz (at the time of this writing) from the above link. Extract it to a directory in your computer.

Launch Visual Studio 2012 Command Prompt by following steps mentioned in these links:
http://neverindoubtnet.blogspot.in/2012/10/add-visual-studio-command-prompt-to.html
http://blogs.msdn.com/b/vcblog/archive/2013/04/19/finding-the-visual-studio-command-prompts-in-visual-studio-2012.aspx

Once Visual Studio 2012 Command Prompt is up, you can use "cd" command to change directory to "winbuild" directory in cURL source.

2:10 PM  
Anonymous Anonymous said...

Hi, I'm on Win8 with Visual 2012 Express Edition and I followed steps, but in winbuild when I run Nmake I get error:nmake: fatal error U1073: don't know how to make VC12

any help?

4:07 AM  
Anonymous Anonymous said...

Hi
I get a linking error "unresolved external symbol __imp__curl_easy_init"
when following your step and using the lib and headers.
How can I get around this ?
Thanks

11:12 PM  
Anonymous Anonymous said...

Found the answer.
Need to add CURL_STATICLIB to project to avoid the linker error. Thanks for the tutorial

11:17 PM  
Anonymous Anonymous said...

Thanks a lot,

After trying to make build it through the IDE and spending tons of hours in many attempts to get it compiled the way I liked, this worked flawlessly. At the first try... I hope I have done this before :\

Thanks once again,
David.

5:42 AM  
Blogger Dinesh Kumar said...

Thanks you for this. I built cURl 7.46 on Windows 8.1 using Visual Studio 2013 - using method above(nmake).

Haven't tested it yet, but should be fine i'm certain.

Thank u :)

3:11 AM  
Blogger Фуад Нуриев said...

Thanks a lot!!!

12:11 AM  

Post a Comment

<< Home