[Libwebsockets] Cross compiling cmake error due to SSL library

"Andy Green (林安廸)" andy at warmcat.com
Sun Nov 24 07:47:20 CET 2013

On 21/11/13 02:02, the mail apparently from Thomas Spitz included:
> Hello everybody,
> I have compiled libwebsockets for my ubuntu PC with success using
> http://git.libwebsockets.org/cgi-bin/cgit/libwebsockets/tree/README.build tutorial.
> Here below a trace of the SSL phase compilation:
> -- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "")
> ZLib include dirs: /usr/include
> ZLib libraries: /usr/lib/x86_64-linux-gnu/libz.so
> Compiling with SSL support
> -- checking for module 'openssl'
> --   found openssl, version 1.0.1
> -- Found OpenSSL:
> /usr/lib/x86_64-linux-gnu/libssl.so;/usr/lib/x86_64-linux-gnu/libcrypto.so
> (found version "1..1")
> OpenSSL include dir: /usr/include
> OpenSSL libraries:
> /usr/lib/x86_64-linux-gnu/libssl.so;/usr/lib/x86_64-linux-gnu/libcrypto.so
> Searching for OpenSSL executable and dlls
> OpenSSL executable: /usr/bin/openssl
> Generating SSL Certificates for the test-server...
> Now I am trying to cross compile libwebsockets for an ARM9 with SSL
> support as it is required for my project.
> I had first some errors for finding Zlib and manage to go throught
> thanks to the following options:
> -DCMAKE_TOOLCHAIN_FILE=./cross-arm-linux-apf28.cmake
> -DZLIB_LIBRARY=/home/thomas/Armadeus/armadeus-git/armadeus/buildroot/output/build/zlib-1.2.7/libz.so
> -DZLIB_INCLUDE_DIR=/home/thomas/Armadeus/armadeus-git/armadeus/buildroot/output/staging/usr/include/

I think that was the right idea but there should be an option to apply 
it globally, ie, tell CMake to go look for libs in


and headers in


instead of the usual places on the host.

But I'm sorry I don't know how to do it and at the moment do not have 
time to research it.

> Now I have fot the following errors due to openssl library:
> ZLib include dirs:
> /home/thomas/Armadeus/armadeus-git/armadeus/buildroot/output/staging/usr/include
> ZLib libraries:
> /home/thomas/Armadeus/armadeus-git/armadeus/buildroot/output/build/zlib-1.2.7/libz.so
> Compiling with SSL support
> CMake Error at
> /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:91
>    Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
>    system variable OPENSSL_ROOT_DIR (missing: OPENSSL_LIBRARIES) (found

Did you try to set OPENSSL_ROOT_DIR?

>    version "1..1")
> Call Stack (most recent call first):
>    /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:252
>    /usr/share/cmake-2.8/Modules/FindOpenSSL.cmake:234
> (find_package_handle_standard_args)
>    CMakeLists.txt:443 (find_package)
> At first it didn't manage to find openssl version. I had to
> had -DOPENSSL_INCLUDE_DIR=/home/thomas/Armadeus/armadeus-git/armadeus/buildroot/output/build/openssl-1.0.1e/include/
> option.

Sounds good.

> I spent hours trying to find the correct options to make it work. Here
> is one of my last tests:
> -DCMAKE_TOOLCHAIN_FILE=./cross-arm-linux-apf28.cmake
> -DZLIB_LIBRARY=/home/thomas/Armadeus/armadeus-git/armadeus/buildroot/output/build/zlib-1.2.7/libz.so
> -DZLIB_INCLUDE_DIR=/home/thomas/Armadeus/armadeus-git/armadeus/buildroot/output/staging/usr/include/
> -DOPENSSL_ROOT_DIR=/home/thomas/Armadeus/armadeus-git/armadeus/buildroot/ -DOPENSSL_INCLUDE_DIR=/home/thomas/Armadeus/armadeus-git/armadeus/buildroot/output/build/openssl-1.0.1e/include/
> -DOPENSSL_LIBRARIES=/home/thomas/Armadeus/armadeus-git/armadeus/buildroot/output/staging/usr/lib
> I compared this cross compilation trace with my PC and search for
> /usr/lib/x86_64-linux-gnu/libssl.so;/usr/lib/x86_64-linux-gnu/libcrypto.so.
> libcrypto.so and libssl.o are both located at
> /home/thomas/Armadeus/armadeus-git/armadeus/buildroot/output/staging/usr/lib
> Should I had them manually (not indicating the folder but the two
> files... but I don't kow how)? Any suggestion?

As I say if you google around there is probably a way to inform cross 
cmake that it should ONLY look down your cross "chroot" paths like 
for all libs, without having to spell it out each time.

> I have seen that some of you already had this kind of problem
> (http://ml.libwebsockets.org/pipermail/libwebsockets/2013-April/000459.html and
> http://stackoverflow.com/questions/16248775/cmake-not-able-to-find-openssl)
> but I didn't managed to find a solution through the reading. By the way,
> on my PC, there is no ssl folder with library in (no
> //usr/local/include/ssl/)/
> Hope you could help me.

Sorry I can't be more help.

If your target machine isn't very weak, you can avoid this by building 
native on it.  I have also tested that on ARM with Fedora armhf and it's 


> Thanks in advance
> Best regards,
> Thomas
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> http://ml.libwebsockets.org/mailman/listinfo/libwebsockets

More information about the Libwebsockets mailing list