warmcat/libwebsockets

Appveyor broke today linking OpenSSL

Closed this issue · 8 comments

Call for Windows / Appveyor users to help.

Basically thismorning appveyor https://ci.appveyor.com/project/lws-team/libwebsockets/history was building OK, after unrelated changes it can no longer link "libcrypto" part of openssl.

Old, working link

  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\link.exe /ERRORREPORT:QUEUE /OUT:"C:\projects\libwebsockets\build\bin\Release\libwebsockets-test-server-v2.0.exe" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib lib\Release\websockets_static.lib lib\Release\zlib_internal.lib "C:\OpenSSL-Win32\lib\VC\ssleay32MD.lib" "C:\OpenSSL-Win32\lib\VC\libeay32MD.lib" C:\assets\libuv\libuv.lib ws2_32.lib userenv.lib psapi.lib iphlpapi.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:"C:/projects/libwebsockets/build/bin/Release/libwebsockets-test-server-v2.0.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:/projects/libwebsockets/build/lib/Release/libwebsockets-test-server-v2.0.lib" /MACHINE:X86 /SAFESEH   /machine:X86 "test-server-v2.0.dir\Release\test-server-v2.0.obj"

New broken link

 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\link.exe /ERRORREPORT:QUEUE /OUT:"C:\projects\libwebsockets\build\bin\Release\libwebsockets-test-server-v2.0.exe" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib lib\Release\websockets_static.lib lib\Release\zlib_internal.lib "C:\OpenSSL-Win32\lib\VC\libssl32MD.lib" "C:\OpenSSL-Win32\lib\VC\libcrypto32MD.lib" C:\assets\libuv\libuv.lib ws2_32.lib userenv.lib psapi.lib iphlpapi.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:"C:/projects/libwebsockets/build/bin/Release/libwebsockets-test-server-v2.0.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:/projects/libwebsockets/build/lib/Release/libwebsockets-test-server-v2.0.lib" /MACHINE:X86 /SAFESEH   /machine:X86 "test-server-v2.0.dir\Release\test-server-v2.0.obj"

Basically it tries now to link "C:\OpenSSL-Win32\lib\VC\libssl32MD.lib" "C:\OpenSSL-Win32\lib\VC\libcrypto32MD.lib" all of a sudden, where before it tried to link "C:\OpenSSL-Win32\lib\VC\ssleay32MD.lib" "C:\OpenSSL-Win32\lib\VC\libeay32MD.lib".

I guess something changed at appveyor. I updated the windows OpenSSL version to the newest 1.0.2L but it's the same.

I stopped it trying to cache openssl pieces since I read it can sometimes get a corrupt cache at Appveyor... no difference.

Any ideas?

I had the last working build on appveyor rebuild from the same commit (7917fe8), and this time it broke the same way as newer builds.

"C:\projects\libwebsockets\build\ALL_BUILD.vcxproj" (default target) (1) ->
"C:\projects\libwebsockets\build\test-server-v2.0.vcxproj" (default target) (22) ->
  websockets_static.lib(ssl.obj) : error LNK2019: unresolved external symbol _CRYPTO_cleanup_all_ex_data referenced in function _lws_ssl_context_destroy [C:\projects\libwebsockets\build\test-server-v2.0.vcxproj]
  websockets_static.lib(ssl.obj) : error LNK2019: unresolved external symbol _OPENSSL_add_all_algorithms_noconf referenced in function _lws_context_init_ssl_library [C:\projects\libwebsockets\build\test-server-v2.0.vcxproj]
  websockets_static.lib(ssl.obj) : error LNK2019: unresolved external symbol _EVP_cleanup referenced in function _lws_ssl_context_destroy [C:\projects\libwebsockets\build\test-server-v2.0.vcxproj]
  websockets_static.lib(ssl.obj) : error LNK2019: unresolved external symbol _SSL_load_error_strings referenced in function _lws_context_init_ssl_library [C:\projects\libwebsockets\build\test-server-v2.0.vcxproj]
  websockets_static.lib(ssl.obj) : error LNK2019: unresolved external symbol _SSL_library_init referenced in function _lws_context_init_ssl_library [C:\projects\libwebsockets\build\test-server-v2.0.vcxproj]
  websockets_static.lib(ssl.obj) : error LNK2019: unresolved external symbol _SSL_get_ex_new_index referenced in function _lws_context_init_ssl_library [C:\projects\libwebsockets\build\test-server-v2.0.vcxproj]
  websockets_static.lib(ssl.obj) : error LNK2019: unresolved external symbol _SSL_CTX_get_ex_new_index referenced in function _lws_context_init_ssl_library [C:\projects\libwebsockets\build\test-server-v2.0.vcxproj]
  websockets_static.lib(ssl.obj) : error LNK2019: unresolved external symbol _SSL_COMP_free_compression_methods referenced in function _lws_ssl_context_destroy [C:\projects\libwebsockets\build\test-server-v2.0.vcxproj]
  websockets_static.lib(ssl.obj) : error LNK2019: unresolved external symbol _ERR_free_strings referenced in function _lws_ssl_context_destroy [C:\projects\libwebsockets\build\test-server-v2.0.vcxproj]
  websockets_static.lib(ssl-server.obj) : error LNK2019: unresolved external symbol _SSLv23_server_method referenced in function _lws_context_init_server_ssl [C:\projects\libwebsockets\build\test-server-v2.0.vcxproj]
  websockets_static.lib(ssl-client.obj) : error LNK2019: unresolved external symbol _SSLv23_client_method referenced in function _lws_context_init_client_ssl [C:\projects\libwebsockets\build\test-server-v2.0.vcxproj]
  C:\projects\libwebsockets\build\bin\Release\libwebsockets-test-server-v2.0.exe : fatal error LNK1120: 11 unresolved externals [C:\projects\libwebsockets\build\test-server-v2.0.vcxproj]

So something changed at appveyor, since it's the exact same commit from us.

Hmm I would guess this has to do with the CMake FindOpenSSL script getting confused with the new version of something.

All this depends on the version of CMake used on Appveyor, and which OpenSSL version.

I would guess it's somewhere in this code it gets things wrong:
https://github.com/Kitware/CMake/blob/master/Modules/FindOpenSSL.cmake#L101-L211

They mention OpenSSL 1.1 in there so I guess it should be able to handle 1.0.2 fine... but this is CMake master branch.

My first try would be to copy this latest version of the FindOpenSSL.cmake into the cmake/ dir in Libwebsockets and see if that helps. CMake should then pick that instead of the one installed on the system first.
(I mean this version: https://github.com/Kitware/CMake/blob/master/Modules/FindOpenSSL.cmake)

Don't really have time to dig deep into this myself right now though.

I added in

 cmake/FindOpenSSL.cmake
 cmake/FindPackageHandleStandardArgs.cmake
 cmake/FindPackageMessage.cmake
 cmake/SelectLibraryConfigurations.cmake 

from there, the extra files are dependent includes, cmake completes but same result with the "libcrypto" errors.

The only diff between 3.8.2 (my version... I dunno what version they were using) for FindOpenSSL.cmake is

--- 3.8.2.cmake	2017-07-19 20:56:22.094060265 +0800
+++ latest.cmake	2017-07-19 20:56:39.001117834 +0800
@@ -162,6 +162,7 @@
         libcrypto
         libeay32${_OPENSSL_MSVC_RT_MODE}
         libeay32
+        crypto
       NAMES_PER_DIR
       ${_OPENSSL_ROOT_HINTS_AND_PATHS}
       PATH_SUFFIXES

I commented "crypto" but didn't help.

Then I tried hacking out the libblah forms

diff -urN latest.cmake cmake/FindOpenSSL.cmake 
--- latest.cmake	2017-07-19 20:56:39.001117834 +0800
+++ cmake/FindOpenSSL.cmake	2017-07-19 21:06:47.961191345 +0800
@@ -144,9 +144,9 @@
 
     find_library(LIB_EAY_DEBUG
       NAMES
-        libcrypto${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
-        libcrypto${_OPENSSL_MSVC_RT_MODE}d
-        libcryptod
+      #    libcrypto${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
+      #  libcrypto${_OPENSSL_MSVC_RT_MODE}d
+      #  libcryptod
         libeay32${_OPENSSL_MSVC_RT_MODE}d
         libeay32d
       NAMES_PER_DIR
@@ -157,12 +157,12 @@
 
     find_library(LIB_EAY_RELEASE
       NAMES
-        libcrypto${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
-        libcrypto${_OPENSSL_MSVC_RT_MODE}
-        libcrypto
+      #        libcrypto${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
+      #  libcrypto${_OPENSSL_MSVC_RT_MODE}
+      # libcrypto
         libeay32${_OPENSSL_MSVC_RT_MODE}
         libeay32
-        crypto
+	#crypto
       NAMES_PER_DIR
       ${_OPENSSL_ROOT_HINTS_AND_PATHS}
       PATH_SUFFIXES
@@ -171,9 +171,9 @@
 
     find_library(SSL_EAY_DEBUG
       NAMES
-        libssl${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
-        libssl${_OPENSSL_MSVC_RT_MODE}d
-        libssld
+      # libssl${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
+      # libssl${_OPENSSL_MSVC_RT_MODE}d
+      # libssld
         ssleay32${_OPENSSL_MSVC_RT_MODE}d
         ssleay32d
       NAMES_PER_DIR
@@ -184,9 +184,9 @@
 
     find_library(SSL_EAY_RELEASE
       NAMES
-        libssl${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
-        libssl${_OPENSSL_MSVC_RT_MODE}
-        libssl
+      #       libssl${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
+      #  libssl${_OPENSSL_MSVC_RT_MODE}
+      #  libssl
         ssleay32${_OPENSSL_MSVC_RT_MODE}
         ssleay32
         ssl

That "solves" it for Appveyor, it can build again.

But the new cmake pieces break Mac build on Travis.

The appveyor guy mentioned they have their own OpenSSL pieces in the image now they just updated.

The new pieces seem to use the newer "libcrypto" type naming not this ancient libeay thing specific to windows, then the OpenSSL pieces we bring in on top with the old naming confuses cmake's FindOpenSSL.

I removed the cmake hack bits that were useful for diagnosis, and instead stopped bringing in our OpenSSL and just use the one now already in the image, problem solved.

Thanks a lot for the pretty accurate help under the circumstances.

Hi. I am Trying to build example_client_hello_world on version 0.11.0 (Windows 7, Visual Studio 2019), I get the following error.

And it looks like I'm getting the same error

image

Please tell me, for version >OF 0.9.8 is there a working solution?

example_client_hello_world

That's not anything from lws.

Lws has like 80 simple and clean minimal examples of its own

And there's some recent build cheatsheet here for windows

https://libwebsockets.org/git/libwebsockets/tree/READMEs/README.build-windows.md

Your problem seems you're not linking libssl tho.

Yes sorry, wrong issue, I wrote this for ofxLibwebsockets