I am coding an encryption program for educational purposes. I am using openssl as the encryption library. The problem is that I want to produce an executable that can run on systems without openssl installed. Therefor I need to link openssl statically. I am using a cmake_list for building.
As soon as I add the flag OPENSSL_USE_STATIC_LIBS
TRUE
I get linker errors...
I have tried building openssl from sources and passing it to the find_package command but this still gives me a linker error for all openssl headers.
'''c++
cmake_minimum_required(VERSION 3.13)
project(encryption_test)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(OPENSSL_ROOT_DIR /usr/local/ssl)
set(OPENSSL_USE_STATIC_LIBS TRUE)
find_package(OpenSSL REQUIRED)
include_directories(
include/)
add_executable(${PROJECT_NAME}
src/main.cpp)
target_link_libraries(${PROJECT_NAME}
stdc++fs
OpenSSL::SSL)
'''
The errors are like:
undefined reference to 'pthread_rwlock_init'
So many thanks for any help or ideas how I can fix this!