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.

22 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  
Blogger kongponleu88 said...

thanks for sharing this great blog.
please click here
gclub จีคลับ
gclub online
baccarat

7:34 AM  
Blogger Anonymous said...

BramhaCorp provides Spacious 2 BHK & 3 BHK flats in Bavdhan Pune and Shops in Bavdhan , with all modern properties in Pune and closely connected facilities Flats in Bavdhan.

5:39 PM  
Blogger Shobhit Tyagi said...

Hi ,
I have successfully link the curl with ssl but it still requires ssleay32.dll and libeay32.dll in my system folder

I want to include both these dll into my executable.

So How to achieve this?

6:10 PM  
Blogger Maitreya Buddha said...

If my memory serves me right, the build process mentioned in this blog, produces BOTH DLLs(for dynamic linking) AND .LIBs for static linking; hence the title for the blog. :)
the static libraries are called "libcurl_a.lib"(release mode) and libcurl_a_debug.lib".

I have them built for Visual Studio 2008, 2010, 2013 and 2015; in both 32-bit and 64-bit(I think) and in DEBUG and RELEASE modes. If you want I can send them over to you by file share or something?

6:22 PM  
Blogger Shobhit Tyagi said...

I am using libcurl_a_debug.lib for static linking but when i use my application it still needs libeay32 and ssleay32 into system folder otherwise it gives me the following error.

The program can't start because LIBEAY32.dll is missing from your computer. Try reinstalling the program to fix this problem.

12:28 PM  
Blogger Shobhit Tyagi said...

Any help regarding the above issue would be highly appreciated.

7:05 PM  
Blogger Maitreya Buddha said...

Sorry about the slight delay- I'm a retired engineer.

I just remembered you have to use the Pre-processor definition :
CURL_STATICLIB
to use static CURL libs.
IN Visual Studio, that's done by right clicking n your VS solution/project, select PROPERTIES from the Pop-up menu, Connfiguration Options/C-C++/Pre-Processor/Pre Processor Definitions

7:23 PM  
Blogger Shobhit Tyagi said...

I am already doing this thing but still getting the same issue.

Why it is looking for libeay32.dll and ssleay32.dll from system folder.

I have downloaded the openssl-win32 from installer and it places both these dll into system folder automatically.

But when I remove these dll from system folder it start giving me the same error.

7:38 PM  
Blogger Maitreya Buddha said...

OpenSSL-win32 probably is NOT built as staitc libs(I don't know); but I thought you were BUILDING OpenSSL from source; and my answer was for that scenario, as then you specify to the build tools that u want the output as a static library. See below:
https://stackoverflow.com/questions/3411259/using-libcurl-without-dll

Internet has lots of help on this matter.

I will leave at this. Good luck!

7:41 PM  
Blogger Shobhit Tyagi said...

Thanks a lot for your help.

Could you please provide me the already built static libraries which you have for visual studio 2010 and visual studio 2013 for both debug and release mode as I am getting an error while building openssl from source.

My mail id : depsite.tyagi.shobhit@gmail.com

7:47 PM  
Blogger Shobhit Tyagi said...

You have mentioned in your comment

Win32 OpenSSL:
Download Win32 OpenSSL installer from here - these are Win32 OpenSSL v1.0.1e and Visual C++ 2008 Redistributables at the time of this writing.
Install Win32 OpenSSL; by default it installs to C:\OpenSSL-Win32.
Install Visual C++ 2008 redistributable.

I am downloading this thing from the same location.

7:51 PM  
Blogger Maitreya Buddha said...


http://www.maitreya-the-christ.com/FTP/__cURL_StaticLibraries_ForVIsualStudio_2008_to_2015.zip

This ZIP file contains pre-built Static Libs for ALL versions of VS, debug and release

7:56 PM  
Blogger Silver88.com said...

Please keep updated this blog, it's been too long. Great post! We adore this blog and This information is very good.
คาสิโนออนไลน์!
บาคาร่าออนไลน์!
ฟุตบอลออนไลน์!
หวยออนไลน์!

7:45 PM  
Blogger Rohit Singh said...

This is a nice post. Thanks so much and let keep on sharing your stuffs keep it up. written content. I added new knowledge to my database for essay writing skill.
Best Mobile Phones under Rs.10,000
Best budget smartphones
Mobiles Phones Under 10000
Mobile Phones Under Rs 10000
Best Mobiles Under Rs 10000
Top 10 Best phones Under Rs 10000
Best Phones under Rs 10000

3:43 PM  

Post a Comment

<< Home