warmcat / libwebsockets

canonical libwebsockets.org networking library
https://libwebsockets.org
Other
4.75k stars 1.48k forks source link

‘ctx’ has incomplete type error when cross compiling libwebsockets #2162

Closed CVVDN-S closed 3 years ago

CVVDN-S commented 3 years ago

Hi, I'm trying to cross compile libwebsockets for arm. I put OpenSSL and Zlib path in CMakefiles.txt. But after command "make", it makes error.

Openssl lib linked as below: SET(OPENSSL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/openssl-1.1.1/build) SET(OPENSSL_LIBRARIES ${CMAKE_CURRENT_SOURCE_DIR}/openssl-1.1.1/build/lib) SET(OPENSSL_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/openssl-1.1.1/build/include) SET(OPENSSL_CRYPTO_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/openssl-1.1.1/build/lib/libcrypto.so) SET(OPENSSL_SSL_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/openssl-1.1.1/build/lib/libssl.so)

The error i get on making : Scanning dependencies of target GENHDR [ 1%] Creating build include dir [ 1%] Built target GENHDR Scanning dependencies of target websockets [ 2%] Building C object lib/CMakeFiles/websockets.dir/plat/unix/unix-caps.c.obj In file included from /home/vkchlt0164/VVDN/Projects/vvdn_t31c/src/ISVP-T31-1.1.2-20201021/software/sdk/Ingenic-SDK-T31-1.1.2-20201021/t31c_app/network/network_interface/websocket/server/libwebsockets-main/include/libwebsockets.h:632:0, from /home/vkchlt0164/VVDN/Projects/vvdn_t31c/src/ISVP-T31-1.1.2-20201021/software/sdk/Ingenic-SDK-T31-1.1.2-20201021/t31c_app/network/network_interface/websocket/server/libwebsockets-main/lib/core/./private-lib-core.h:140, from /home/vkchlt0164/VVDN/Projects/vvdn_t31c/src/ISVP-T31-1.1.2-20201021/software/sdk/Ingenic-SDK-T31-1.1.2-20201021/t31c_app/network/network_interface/websocket/server/libwebsockets-main/lib/plat/unix/unix-caps.c:28: /home/vkchlt0164/VVDN/Projects/vvdn_t31c/src/ISVP-T31-1.1.2-20201021/software/sdk/Ingenic-SDK-T31-1.1.2-20201021/t31c_app/network/network_interface/websocket/server/libwebsockets-main/include/libwebsockets/lws-genhash.h:85:18: error: field 'ctx' has incomplete type HMAC_CTX ctx; ^ lib/CMakeFiles/websockets.dir/build.make:62: recipe for target 'lib/CMakeFiles/websockets.dir/plat/unix/unix-caps.c.obj' failed make[2]: [lib/CMakeFiles/websockets.dir/plat/unix/unix-caps.c.obj] Error 1 CMakeFiles/Makefile2:1068: recipe for target 'lib/CMakeFiles/websockets.dir/all' failed make[1]: [lib/CMakeFiles/websockets.dir/all] Error 2 Makefile:160: recipe for target 'all' failed make: *** [all] Error 2

Error from CMakeError.log : /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_d8b0c.dir/link.txt --verbose=1 /opt/mips-gcc540-glibc222-64bit-r3.3.0/bin/mips-linux-gnu-gcc -Wall -Wsign-compare -fvisibility=hidden -Wuninitialized -Wtype-limits -Wignored-qualifiers -Werror -DCHECK_FUNCTION_EXISTS=TLSv1_2_client_method CMakeFiles/cmTC_d8b0c.dir/CheckFunctionExists.c.obj -o cmTC_d8b0c /home/vkchlt0164/VVDN/Projects/vvdn_t31c/src/ISVP-T31-1.1.2-20201021/software/sdk/Ingenic-SDK-T31-1.1.2-20201021/t31c_app/network/network_interface/websocket/server/libwebsockets-main/openssl-1.1.1/build/lib/libssl.a /home/vkchlt0164/VVDN/Projects/vvdn_t31c/src/ISVP-T31-1.1.2-20201021/software/sdk/Ingenic-SDK-T31-1.1.2-20201021/t31c_app/network/network_interface/websocket/server/libwebsockets-main/openssl-1.1.1/build/lib/libcrypto.a -lpthread /home/vkchlt0164/VVDN/Projects/vvdn_t31c/src/ISVP-T31-1.1.2-20201021/software/sdk/Ingenic-SDK-T31-1.1.2-20201021/t31c_app/network/network_interface/websocket/server/libwebsockets-main/openssl-1.1.1/build/lib/libcrypto.a(dso_dlfcn.o): In function dlfcn_globallookup': dso_dlfcn.c:(.text+0xc): undefined reference todlopen' dso_dlfcn.c:(.text+0x2c): undefined reference to dlopen' dso_dlfcn.c:(.text+0x3c): undefined reference todlsym' dso_dlfcn.c:(.text+0x48): undefined reference to dlsym' dso_dlfcn.c:(.text+0x58): undefined reference todlclose' dso_dlfcn.c:(.text+0x5c): undefined reference to dlclose' /home/vkchlt0164/VVDN/Projects/vvdn_t31c/src/ISVP-T31-1.1.2-20201021/software/sdk/Ingenic-SDK-T31-1.1.2-20201021/t31c_app/network/network_interface/websocket/server/libwebsockets-main/openssl-1.1.1/build/lib/libcrypto.a(dso_dlfcn.o): In functiondlfcn_bind_func': dso_dlfcn.c:(.text+0x42c): undefined reference to dlsym' dso_dlfcn.c:(.text+0x434): undefined reference todlsym' dso_dlfcn.c:(.text+0x4fc): undefined reference to dlerror' dso_dlfcn.c:(.text+0x500): undefined reference todlerror' /home/vkchlt0164/VVDN/Projects/vvdn_t31c/src/ISVP-T31-1.1.2-20201021/software/sdk/Ingenic-SDK-T31-1.1.2-20201021/t31c_app/network/network_interface/websocket/server/libwebsockets-main/openssl-1.1.1/build/lib/libcrypto.a(dso_dlfcn.o): In function dlfcn_load': dso_dlfcn.c:(.text+0x598): undefined reference todlopen' dso_dlfcn.c:(.text+0x5ac): undefined reference to dlopen' dso_dlfcn.c:(.text+0x64c): undefined reference todlclose' dso_dlfcn.c:(.text+0x650): undefined reference to dlclose' dso_dlfcn.c:(.text+0x6a4): undefined reference todlerror' dso_dlfcn.c:(.text+0x6a8): undefined reference to dlerror' /home/vkchlt0164/VVDN/Projects/vvdn_t31c/src/ISVP-T31-1.1.2-20201021/software/sdk/Ingenic-SDK-T31-1.1.2-20201021/t31c_app/network/network_interface/websocket/server/libwebsockets-main/openssl-1.1.1/build/lib/libcrypto.a(dso_dlfcn.o): In functiondlfcn_pathbyaddr': dso_dlfcn.c:(.text+0x778): undefined reference to dladdr' dso_dlfcn.c:(.text+0x77c): undefined reference todladdr' dso_dlfcn.c:(.text+0x81c): undefined reference to dlerror' dso_dlfcn.c:(.text+0x820): undefined reference todlerror' /home/vkchlt0164/VVDN/Projects/vvdn_t31c/src/ISVP-T31-1.1.2-20201021/software/sdk/Ingenic-SDK-T31-1.1.2-20201021/t31c_app/network/network_interface/websocket/server/libwebsockets-main/openssl-1.1.1/build/lib/libcrypto.a(dso_dlfcn.o): In function dlfcn_unload': dso_dlfcn.c:(.text+0x898): undefined reference todlclose' dso_dlfcn.c:(.text+0x89c): undefined reference to `dlclose' collect2: error: ld returned 1 exit status CMakeFiles/cmTC_d8b0c.dir/build.make:99: recipe for target 'cmTC_d8b0c' failed make[1]: *** [cmTC_d8b0c] Error 1

CVVDN-S commented 3 years ago

list(APPEND LIB_LIST dl) -- by adding this was able resolve it. Sorry for this silly mistake.

lws-team commented 3 years ago

It looks like your openssl needs to be linked with dl (eg, -ldl at link-time)

/home/vkchlt0164/VVDN/Projects/vvdn_t31c/src/ISVP-T31-1.1.2-20201021/software/sdk/Ingenic-SDK-T31-1.1.2-20201021/t31c_app/network/network_interface/websocket/server/libwebsockets-main/openssl-1.1.1/build/lib/libcrypto.a(dso_dlfcn.o): In function dlfcn_globallookup': dso_dlfcn.c:(.text+0xc): undefined reference to dlopen'

The problem is coming because openssl wants it, but presumably you have configured lws to not need it.

You can maybe work around by enabling LWS_WITH_PLUGINS, it will cause lws to want dl itself.

list(APPEND LIB_LIST dl)

this is a bit of a hack though if you need to edit the lws CMakeLists.txt for that. I don't think it's silly or a mistake, cross build can be very tricky to get right.