Menu

#1488 Building libcurl 7.41.0 with OpenSSL on Windows using VC makefile fails (+ solution)

closed-fixed
5
2015-03-05
2015-03-05
No

Hello,

I am building libcurl 7.41.0 using VC 12 on Windows 8.1 64-bit with the following command:

nmake /f Makefile.vc MODE=static WITH_SSL=static WITH_CARES=static WITH_ZLIB=static GEN_PDF=no DEBUG=false VC=12 RTLIBCFG=static

The compiler output contains various errors describing that structures such as OCSP_BASICRESP (access on line lib/vtls/openssl.c:1337) are undefined.
Related thread on mailing list (I did not post there, but it turned up on Google and did not contain a solution) containing compiler output:
http://curl.haxx.se/mail/lib-2015-02/0197.html

The cause for this issue apparently is a recently introduced check for USE_OPENSSL on line 58 of openssl.c. When not defined, some OpenSSL headers (such as ocsp.h) are not included.
The solution is to define USE_OPENSSL in MakefileBuild.vc. Specifically, change line 58 to:

SSL_CFLAGS = /DUSE_SSLEAY /DUSE_OPENSSL /I"$(DEVEL_INCLUDE)/openssl"

Oliver

Discussion

  • Daniel Stenberg

    Daniel Stenberg - 2015-03-05
    • assigned_to: Daniel Stenberg
     
  • Daniel Stenberg

    Daniel Stenberg - 2015-03-05

    That #ifdef check was introduced 2004-12-14, a little over 10 years ago. I don't consider that "recent"... So how did it work before?

     
  • Oliver Kuckertz

    Oliver Kuckertz - 2015-03-05

    Haha, I have no idea. OpenSSL's ocsp.h was probably pulled in indirectly before (Maybe by older OpenSSL versions? I built a fresh copy of the latest version for this project just now.) Some other change within libcurl might be related to this too. This must be something more recent than the USE_OPENSSL check that I initially suspected - it cannot be coincidence that a similar post appeared on the mailing list a week ago.

    Verification of that issue however is trivial: Insert an #error directive right after the #ifdef USE_OPENSSL, and it will abort the compilation without the suggested patch.

     
  • Daniel Stenberg

    Daniel Stenberg - 2015-03-05

    Well, not trivial for me since I don't build on Windows at all! :-)

    This however triggered me to do the change slightly different: I've now committed a change that removed all our use of USE_SSLEAY and instead make sure we only ever use USE_OPENSSL when we check for openssl. I think it will lead to the same end result: that it builds fine even on Windows.

    It'd be great if you could verify if the latest git builds for you. I also announced this change on the mailing list just now so that people are aware in case this (drastic) change causes any other problems.

     
  • Oliver Kuckertz

    Oliver Kuckertz - 2015-03-05

    The current git head compiles with VS2013's x86 and x64 toolchain. A quick 'curl -k https://www.google.com' call succeeded. Thank you for fixing this!

     
  • Daniel Stenberg

    Daniel Stenberg - 2015-03-05
    • labels: --> compile or build problem, windows build
    • status: open --> closed-fixed
     
  • Daniel Stenberg

    Daniel Stenberg - 2015-03-05

    Lovely, thanks for the quick confirmation. Case closed!