Repository navigation
setting up the helloworld example for cmake build; building with ixwebsocket library #541
Copy link
Copy link
Open
Description
Please pardon my ignorance. I'm new to CMake.
I appear to have successfully built and install ixwebsocket with the final sudo make install
I've created a main.cpp file from the example shown at here
I've placed the main.cpp in a directory and added a CMakeLists.txt file:
cmake_minimum_required(VERSION 3.14)
set (CMAKE_CXX_STANDARD 14)
project(test1 C CXX)
find_package(ixwebsocket)
add_executable(test1 main.cpp)
target_link_libraries (test1 ixwebsocket)
install(TARGETS test1 DESTINATION bin)
I'm sure my CMakeLists.txt file is the problem.
When I run cmake .. from the ../build dir I don't get any cmake errors.
However, when i run make I get a lot of link errors, "undefined references". I know what this typically means but I'm not sure how to get the CMakefile insures that the objects are found.
Here's a brief list of the kinds of errors I'm getting:
tim-testing/build$ make
[ 50%] Building CXX object CMakeFiles/test1.dir/main.cpp.o
[100%] Linking CXX executable test1
/usr/bin/ld: /usr/local/lib/libixwebsocket.a(IXWebSocketPerMessageDeflateCodec.cpp.o): in function `bool ix::WebSocketPerMessageDeflateCompressor::compressData<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) [clone .part.0]':
IXWebSocketPerMessageDeflateCodec.cpp:(.text+0x6f): undefined reference to `deflate'
/usr/bin/ld: /usr/local/lib/libixwebsocket.a(IXWebSocketPerMessageDeflateCodec.cpp.o): in function `ix::WebSocketPerMessageDeflateCompressor::~WebSocketPerMessageDeflateCompressor()':
IXWebSocketPerMessageDeflateCodec.cpp:(.text+0x3e0): undefined reference to `deflateEnd'
/usr/bin/ld: /usr/local/lib/libixwebsocket.a(IXWebSocketPerMessageDeflateCodec.cpp.o): in function `ix::WebSocketPerMessageDeflateCompressor::init(unsigned char, bool)':
IXWebSocketPerMessageDeflateCodec.cpp:(.text+0x42a): undefined reference to `deflateInit2_'
/usr/bin/ld: /usr/local/lib/libixwebsocket.a(IXWebSocketPerMessageDeflateCodec.cpp.o): in function `ix::WebSocketPerMessageDeflateCompressor::compress(ix::IXWebSocketSendData const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)':
IXWebSocketPerMessageDeflateCodec.cpp:(.text+0x627): undefined reference to `deflate'
/usr/bin/ld: /usr/local/lib/libixwebsocket.a(IXWebSocketPerMessageDeflateCodec.cpp.o): in function `ix::WebSocketPerMessageDeflateDecompressor::~WebSocketPerMessageDeflateDecompressor()':
[.....]
[clone .part.0]':
IXWebSocketPerMessageDeflateCodec.cpp:(.text+0xe8d): undefined reference to `deflate'
/usr/bin/ld: /usr/local/lib/libixwebsocket.a(IXSocketOpenSSL.cpp.o): in function `ix::SocketOpenSSL::openSSLInitialize()':
IXSocketOpenSSL.cpp:(.text+0x20): undefined reference to `OPENSSL_init_ssl'
/usr/bin/ld: IXSocketOpenSSL.cpp:(.text+0x2d): undefined reference to `OPENSSL_init_ssl'
/usr/bin/ld: IXSocketOpenSSL.cpp:(.text+0x39): undefined reference to `OPENSSL_init_ssl'
/usr/bin/ld: /usr/local/lib/libixwebsocket.a(IXSocketOpenSSL.cpp.o): in function `ix::SocketOpenSSL::send(char*, unsigned long)':
IXSocketOpenSSL.cpp:(.text+0x93): undefined reference to `ERR_clear_error'
/usr/bin/ld: IXSocketOpenSSL.cpp:(.text+0xa2): undefined reference to `SSL_write'
/usr/bin/ld: IXSocketOpenSSL.cpp:(.text+0xb1): undefined reference to `SSL_get_error'
/usr/bin/ld: /usr/local/lib/libixwebsocket.a(IXSocketOpenSSL.cpp.o): in function `ix::SocketOpenSSL::recv(void*, unsigned long)':
IXSocketOpenSSL.cpp:(.text+0x157): undefined reference to `ERR_clear_error'
/usr/bin/ld: IXSocketOpenSSL.cpp:(.text+0x166): undefined reference to `SSL_read'
/usr/bin/ld: IXSocketOpenSSL.cpp:(.text+0x197): undefined reference to `SSL_get_error'
/usr/bin/ld: /usr/local/lib/libixwebsocket.a(IXSocketOpenSSL.cpp.o): in function `ix::SocketOpenSSL::getSSLError[abi:cxx11](int)':
IXSocketOpenSSL.cpp:(.text+0x82a): undefined reference to `SSL_get_error'
/usr/bin/ld: IXSocketOpenSSL.cpp:(.text+0x961): undefined reference to `ERR_get_error'
/usr/bin/ld: IXSocketOpenSSL.cpp:(.text+0xb11): undefined reference to `ERR_get_error'
/usr/bin/ld: IXSocketOpenSSL.cpp:(.text+0xb76): undefined reference to `ERR_error_string'
/usr/bin/ld: IXSocketOpenSSL.cpp:(.text+0xcae): undefined reference to `ERR_error_string'
/usr/bin/ld: /usr/local/lib/libixwebsocket.a(IXSocketOpenSSL.cpp.o): in function `ix::SocketOpenSSL::openSSLCreateContext(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)':
IXSocketOpenSSL.cpp:(.text+0xd6f): undefined reference to `TLS_client_method'
/usr/bin/ld: IXSocketOpenSSL.cpp:(.text+0xd83): undefined reference to `SSL_CTX_new'
/usr/bin/ld: IXSocketOpenSSL.cpp:(.text+0xd9f): undefined reference to `SSL_CTX_ctrl'
[...]
Please help. Thanks
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
bsergean commentedon Feb 12, 2025
You need to disable zlib and openssl (or any ssl library) if you aren't adding them to the linker line.
bsergean commentedon Feb 12, 2025
Run cmake like this
USE_ZLIB=OFF
USE_TLS=OFF
It will limit capacities but will unblock you.