Building libcurl with SSL support on Windows?

Well, since this post failed badly, I had to dig into the matter myself Also check out the other answers and comments for additional info regarding other versions etc EDIT: Since I posted this Q there seems to be ready-built binaries made available from the curl homepage. Check out James' answer So here goes: Preprocessor The following two symbols need to be fed to the preprocessor to enable SSL for libcurl: USE_SSLEAY USE_OPENSSL (libcurl uses OpenSSL for SSL support) Alternatively the symbols can be added directly to a file called setup. H in libcurl, but I'm not too happy about modifying code in 3rd party distributions unless I really have to Rebuilding the libcurl library, I now got some errors about OpenSSL include files not being found.

Naturally, since I haven't set up the OpenSSL distribution properly yet Compiling OpenSSL binaries I downloaded the OpenSSL 0.9.8 source distribution and unpacked it In the root of the source distribution there's a file called INSTALL. W32 which describes how to compile the OpenSSL binaries. The build chain requires perl, so I installed the latest version of ActivePerl I had some trouble with the build, which might not be applicable to all systems, but I'll go through it here in case somebody experiences the same According to INSTALL.

W32: Run the following commandline tasks with current directory set to the source distribution root: 1> perl Configure VC-WIN32 --prefix=c:/some/openssl/dir (Where "c:/some/openssl/dir" should be replaced by the dir where OpenSSL should be installed. Don't use spaces in this path. The compilation further ahead will fail in that case) 2> ms\do_ms For me this step was unsuccessful at first, since I lacked the environment variables OSVERSION and TARGETCPU.

I set these to 5.1.2600 and x86 respectively. You may get complaint about OSVERSION being "insane", but look closer, this error is for WinCE and doesn't affect the Win32 setup. To get hold of your OS version, run the 'ver' command from a command prompt or run winver.

Exe 3> nmake -f ms\nt. Mak (for static library) or 3> nmake -f ms\ntdll. Mak (for DLL) The source now compiles.

Took approx 5 minutes on my laptop.

Well, since this post failed badly, I had to dig into the matter myself. Also check out the other answers and comments for additional info regarding other versions etc. EDIT: Since I posted this Q there seems to be ready-built binaries made available from the curl homepage. Check out James' answer.

So here goes: - Preprocessor The following two symbols need to be fed to the preprocessor to enable SSL for libcurl: USE_SSLEAY USE_OPENSSL (libcurl uses OpenSSL for SSL support) Alternatively the symbols can be added directly to a file called setup. H in libcurl, but I'm not too happy about modifying code in 3rd party distributions unless I really have to. Rebuilding the libcurl library, I now got some errors about OpenSSL include files not being found.

Naturally, since I haven't set up the OpenSSL distribution properly yet. Compiling OpenSSL binaries I downloaded the OpenSSL 0.9.8 source distribution and unpacked it.In the root of the source distribution there's a file called INSTALL. W32 which describes how to compile the OpenSSL binaries.

The build chain requires perl, so I installed the latest version of ActivePerl. I had some trouble with the build, which might not be applicable to all systems, but I'll go through it here in case somebody experiences the same. According to INSTALL.

W32: Run the following commandline tasks with current directory set to the source distribution root: 1> perl Configure VC-WIN32 --prefix=c:/some/openssl/dir (Where "c:/some/openssl/dir" should be replaced by the dir where OpenSSL should be installed. Don't use spaces in this path. The compilation further ahead will fail in that case) 2> ms\do_ms For me this step was unsuccessful at first, since I lacked the environment variables OSVERSION and TARGETCPU.

I set these to 5.1.2600 and x86 respectively. You may get complaint about OSVERSION being "insane", but look closer, this error is for WinCE and doesn't affect the Win32 setup. To get hold of your OS version, run the 'ver' command from a command prompt or run winver.exe.

3> nmake -f ms\nt. Mak (for static library) or 3> nmake -f ms\ntdll. Mak (for DLL) The source now compiles.

Took approx 5 minutes on my laptop. When compilation is completed, the libs or binaries have been placed in: distroot/out32 - for static library build or distroot/out32dll - for DLL build Building and linking Now, back to visual studio and point out the libs and include path for headers. The include files are located in distroot/inc32/openssl.

Remember to add libeay32. Lib and ssleay32. Lib as linker input.

Rebuild the libcurl project. Error! Well at least for me with this version of OpenSSL.

It complained about a struct typedef in one of the OpenSSL headers. I couldn't find any info on this. After an hour of googling I broke my own principle and commented out the typedef from the OpenSSL header, and luckily libcurl wasn't using that symbol so it built fine.

Update: As pointed out by Jason, this issue seems to have dissapeared as of version 1.0.0a. Now, for confirming that SSL support is enabled for libcurl, run the following code: curl_version_info_data * vinfo = curl_version_info( CURLVERSION_NOW ); if( vinfo->features & CURL_VERSION_SSL ) // SSL support enabled else // No SSL Simple as that.

Thanks helped alot! – Lodle Jul 24 '09 at 8:30 Thank you. Too bad the libcurl guys do not provide something ready to use in Windows.

– Wartin Sep 9 '10 at 14:57 with openssl-1.0.0. A, you don't need to comment out the typedef (last step). It just works.

– Jason Sundram Nov 18 '10 at 21:56 Could you update your (awesome) answer to remind people to add libeay32. Lib and ssleay32. Lib to the linker input for static builds?

– Jason Sundram Nov 18 '10 at 21:57 Also, to find the windows version string, just use Start | Run | winver.exe. – Jason Sundram Nov 18 '10 at 21:58.

When compiling OpenSSL 1.0.0 on Windows with Visual Studio 2010, it eventually threw a 0x2 error: NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0 \VC\BIN\cl. EXE"' : return code '0x2' Stop. It seems that this error will be thrown because of a flag in the perl Configure file, namely -WX.As the MSDN documentation states: Treats all compiler warnings as errors.

For a new project, it may be best to use /WX in all compilations; resolving all warnings will ensure the fewest possible hard-to-find code defects. After removing the -WX occurrences in the Configure file and re-entering the commands stated here it built fine and passed all tests.

1 Or one can fix the redefinition that cause the warning. See the bug report at rt.openssl. Org/Ticket/… – KTC May 21 '10 at 2:09.

Maybe this isn't the answer anyone is looking for, but I simply just downloaded the precompiled dlls from this link found at curl.haxx.se/download.html I ran the test that sharkin provided, and if( vinfo->features & CURL_VERSION_SSL ) proved to be true.

Nice! I guess those bins was added since I posted the Q. It was indeed what I was looking for back then.

– sharkin Mar 1 at 11:00 I downloaded the precompiled dll mentioned, and added libcurl. Dll,libeay32. Dll and libssl32.

Dll as Additional Linker dependencies, but linking fails with the error 1>E:\curl-7.21.4-ssl-sspi-zlib-static-bin-w32\libcurl. Dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x308 – Hugh Darling Apr 19 at 10:50.

I did "do_nt. Bat" for windows 7 rc7100 don't forget "nmake -f ms\nt. Mak install" to copy the headers correctly thanks this did help a lot.

Couple of notes in response to and/or in addition to the above.. First, if you don't want to mess with ActivePerl, Strawberry Perl is terrific and worked perfectly for this. Second, in lieu of using do_ms. Bat, I would recommend preferring do_masm if possible since, according to INSTALL.

W32, This is worth doing because it will result in faster code: for example it will typically result in a 2 times speedup in the RSA routines. Also, build 0.9.8l (L) of OpenSSL was a nightmare so I eventually gave up and reverted to 0.9.8k which built and linked (statically) with libcurl 1.9 without issue.

I downloaded it, and used LoadLibrary(_T("libcurl. Dll")) to add the dll to my project but I get link errors... 1>TestUsingCurl. Obj : error LNK2001: unresolved external symbol _imp_curl_multi_timeout 1>TestUsingCurl.

Obj : error LNK2001: unresolved external symbol _imp_curl_multi_fdset 1>TestUsingCurl. Obj : error LNK2001: unresolved external symbol _imp_curl_multi_perform 1>TestUsingCurl. Obj : error LNK2001: unresolved external symbol _imp_curl_easy_init 1>TestUsingCurl.

Obj : error LNK2001: unresolved external symbol _imp_curl_easy_setopt 1>TestUsingCurl. Obj : error LNK2001: unresolved external symbol _imp_curl_multi_init 1>TestUsingCurl. Obj : error LNK2001: unresolved external symbol _imp_curl_multi_add_handle 1>TestUsingCurl.

Obj : error LNK2001: unresolved external symbol _imp_curl_multi_remove_handle 1>TestUsingCurl. Obj : error LNK2001: unresolved external symbol _imp_curl_easy_cleanup Also... what do you do for the debug version? Thanks, Nadia.

I've got such an error C:\openssl-1.0.0d>nmake -f ms\nt. Mak Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved.

Building OpenSSL cl /Fotmp32\cryptlib. Obj -Iinc32 -Itmp32 /MT /Ox /O2 /Ob2 -DOPENSSL_THR EADS -DDSO_WIN32 -W3 -WX -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_L EAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -DOPENSSL_BN_ASM_PART_WORDS - DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -D MD5_ASM -DRMD160_ASM -DAES_ASM -DWHIRLPOOL_ASM -DOPENSSL_NO_RC5 -DOPENSSL_NO_MD2 -DOPENSSL_NO_KRB5 -DOPENSSL_NO_JPAKE -DOPENSSL_NO_DYNAMIC_ENGINE /Zl /Zi /Fdtmp 32/lib -c . \crypto\cryptlib.

C cryptlib. C c:\openssl-1.0.0d\crypto\cryptlib. H(62) : fatal error C1083: Cannot open include file: 'stdlib.

H': No such file or directory NMAKE : fatal error U1077: 'C:\Windows\system32\cmd. Exe' : return code '0x2' Stop. I added path to include folder on MinGW to the PATH variable - same thing.

– sharkin Aug 29 at 9:51 yes, I use cmd. Exe – Alecs Aug 29 at 9:58 In what capacity is mingw involved? This seems to be rather fundamental and not specific for libcurl buildprocess.

I.e. You'd probably get similar error compiling a main. C with stdlib.

H included, no? – sharkin Aug 29 at 10:20 no, I compile and run any program without problems, but using Eclipse, I didn't try to compile via cmd, 'cos I never do it – Alecs Aug 29 at 10:24 ok, still not sure how mingw comes in to the picture, but I take it that you're not using the microsoft build tools? My solution is based on configuring the build for the VC build chain (e.g. If you have visual studio installed).

– sharkin Aug 29 at 10:44.

I compiled OpenSSL statically, for that downloaded MS VS Express, that compiled libcUrl with OpenSSL, also statically. Added lib-files to my project, try to build g++ -DCURL_STATICLIB -DUSE_SSLEAY -DUSE_OPENSSL -O0 -g3 -Wall -c -fmessage-length=0 -osrc\main. O ..\src\main.

Cpp g++ -L..\lib -oYTUploader. Exe src\main. O -llibcurl -llibeay32 -lssleay32 -lws2_32 -lwldap32 and run into bunch of errors like ..\lib/libeay32.

Lib(tmp32/asn_mime. Obj):(. Text_SMIME_text+0x6): undefined reference to `_chkstk' ..\lib/libeay32.

Lib(tmp32/asn_mime. Obj):(. Text_SMIME_text+0xb): undefined reference to `__security_cookie' ..\lib/libeay32.

Lib(tmp32/asn_mime. Obj):(. Text_SMIME_text+0x63): undefined reference to `@__security_check_cookie@4' ..\lib/libeay32.

Lib(tmp32/asn_mime. Obj):(. Text_SMIME_text+0x19e): undefined reference to `@__security_check_cookie@4' ..\lib/libeay32.

Lib(tmp32/ech_ossl. Obj):(. Text_ecdh_compute_key+0x6): undefined reference to `_chkstk' ..\lib/libeay32.

Lib(tmp32/bio_asn1. Obj):(. Text_asn1_bio_set_ex+0x6): undefined reference to `_chkstk' ..\lib/libeay32.

Lib(tmp32/bio_asn1. Obj):(. Text_asn1_bio_get_ex+0x6): undefined reference to `_chkstk' ..\lib/libeay32.

Lib(tmp32/bio_asn1. Obj):(. Text_BIO_asn1_set_prefix+0x6): undefined reference to `_chkstk' ..\lib/libeay32.

Lib(tmp32/bio_asn1. Obj):(. Text_BIO_asn1_get_prefix+0x6): undefined reference to `_chkstk' ..\lib/libeay32.

Lib(tmp32/bio_asn1. Obj):(. Text_BIO_asn1_set_suffix+0x6): more undefined references to `_chkstk' follow ..\lib/ssleay32.

Lib(tmp32/ssl_lib. Obj):(. Text_SSL_has_matching_session_id+0xb): undefined reference to `__security_cookie' Can someone help with that?

Using Eclipse with MinGW.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions