Failed to link OpenSSL using MinGW/Cmake (TLS_method,`SSL_CTX_ctrl', .etc..) - windows

I'm going crazy to link OpenSSL with project that I'm implementing using MinGW and setting the project with CMake Gui.
It basically fails to link properly with the OpenSSL libraries.
Here's my CMake settings -> https://ibb.co/5Y0TB5Y.
Here there are the CMakeLists.txt that I used in my project:
1. Main CMakeLists.txt
`cmake_minimum_required (VERSION 2.6)
project (MyPluginDesignProject)
SET (BOOST_ROOT "C:\\Program Files\\boost_1_68_0")
SET (BOOST_INCLUDEDIR "C:\\Program Files\\boost_1_68_0\\include")
SET (BOOST_LIBRARYDIR "C:\\Program Files\\boost\\lib")
SET (BOOST_MIN_VERSION "1.68.0")
set (Boost_NO_BOOST_CMAKE ON)
FIND_PACKAGE(Boost ${BOOST_MIN_VERSION} REQUIRED)
if (NOT Boost_FOUND)
message(FATAL_ERROR "Fatal error: Boost (version >= 1.55) required.")
else()
message(STATUS "Setting up BOOST")
message(STATUS " Includes - ${Boost_INCLUDE_DIRS}")
message(STATUS " Library - ${Boost_LIBRARY_DIRS}")
SET (Boost_INCLUDE_DIRS "C:\\Program Files\\boost\\lib")
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
endif (NOT Boost_FOUND)
message("Binary path " ${PROJECT_SOURCE_DIR})
message("Source path " ${PROJECT_BINARY_DIR})
#define the path relative the headers
set (PLUGIN_INCLUDES ${PROJECT_SOURCE_DIR}/Headers)
#telle the compiler to check the headers in the PLUGIN_INCLUDES path for the project's headers
include_directories(${PLUGIN_INCLUDES})
add_subdirectory(Plugins\\MyPlugin)
#define the variable PROJECT_SOURCE that includes all the cpp within the "Headers" folder
set(PROJECT_INCLUDES Headers/GameInstance.h)
#define the variable PROJECT_SOURCE that includes all the cpp within the "Source" folder
set(PROJECT_SOURCE
Source/main.cpp
Source/GameInstance.cpp
)
add_executable(MyPluginDesignProject ${PROJECT_SOURCE})
#Links the library to the program :
# keyword: PRIVATE
target_link_libraries (MyPluginDesignProject PRIVATE MyPlugin)`
2 Plugin CMakeLists.txt
`cmake_minimum_required (VERSION 2.6)
add_subdirectory(ThirdParty\\Simple-Web-Server)
file(GLOB
MYPLUGIN_SERVER_PLUGIN_HEADERS Headers/*.h
)
file(GLOB
MYPLUGIN_SERVER_PLUGIN_SOURCES Source/*.cpp
)
file(GLOB
SIMPLE_WEB_SERVER ThirdParty/Simple-Web-Server/*.hpp
)
add_library(
MyPlugin #name of the library
STATIC #STATIC library . other option: SHARED - MODULE. STATIC is default
${MYPLUGIN_SERVER_PLUGIN_HEADERS}
${MYPLUGIN_SERVER_PLUGIN_SOURCES}
${SIMPLE_WEB_SERVER}
)
find_package(OpenSSL REQUIRED)
if (OPENSSL_FOUND)
include_directories(${OPENSSL_INCLUDE_DIR})
target_link_libraries(MyPlugin PUBLIC ${OPENSSL_LIBRARIES})
endif()
#definition of the include path of the library that will be usedd for linking
#keyword: the "PUBLIC" keyword means that abyone who's including this library, will include also all the
#includes included in this library.
#if the keyword is "PRIVATE" then the program that includes this library won't automatically include its libraries
target_include_directories(MyPlugin PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/Headers)
target_include_directories(MyPlugin PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/Simple-Web-Server)
target_link_libraries(MyPlugin PUBLIC ${OPENSSL_LIBRARIES})
target_link_libraries (MyPlugin PUBLIC simple-web-server)
target_compile_definitions(MyPlugin PUBLIC MYPLUGIN_SERVER_PLUGIN_VERSION=1.2.0)`
SimpleWebServer CMakeLists.txt (included in the plugin CMakeLists.txt)
`
cmake_minimum_required (VERSION 3.0)
project (Simple-Web-Server)
option(USE_STANDALONE_ASIO "set ON to use standalone Asio instead of Boost.Asio" OFF)
option(BUILD_TESTING "set ON to build library tests" OFF)
if(NOT MSVC)
add_compile_options(-std=c++11 -Wall -Wextra -Wsign-conversion)
else()
add_compile_options(/W1)
endif()
add_library(simple-web-server INTERFACE)
target_include_directories(simple-web-server INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
find_package(Threads REQUIRED)
target_link_libraries(simple-web-server INTERFACE ${CMAKE_THREAD_LIBS_INIT})
# TODO 2020 when Debian Jessie LTS ends:
# Remove Boost system, thread, regex components; use Boost::<component> aliases; remove Boost target_include_directories
if(USE_STANDALONE_ASIO)
target_compile_definitions(simple-web-server INTERFACE USE_STANDALONE_ASIO)
include(CheckIncludeFileCXX)
CHECK_INCLUDE_FILE_CXX(asio.hpp HAVE_ASIO)
if(NOT HAVE_ASIO)
message(FATAL_ERROR "Standalone Asio not found")
endif()
else()
find_package(Boost 1.53.0 COMPONENTS system thread REQUIRED)
target_link_libraries(simple-web-server INTERFACE ${Boost_LIBRARIES})
target_include_directories(simple-web-server INTERFACE ${Boost_INCLUDE_DIR})
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
target_compile_definitions(simple-web-server INTERFACE USE_BOOST_REGEX)
find_package(Boost 1.53.0 COMPONENTS regex REQUIRED)
target_link_libraries(simple-web-server INTERFACE ${Boost_LIBRARIES})
target_include_directories(simple-web-server INTERFACE ${Boost_INCLUDE_DIR})
endif()
endif()
if(WIN32)
target_link_libraries(simple-web-server INTERFACE ws2_32 wsock32)
endif()
if(APPLE)
set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl")
endif()
find_package(OpenSSL)
if(OPENSSL_FOUND)
message(STATUS "Using OpenSSL ${OPENSSL_VERSION}")
include_directories(${OPENSSL_INCLUDE_DIRS})
target_compile_definitions(simple-web-server INTERFACE HAVE_OPENSSL)
message ("OpenSSL library is " ${OPENSSL_LIBRARIES})
target_link_libraries(simple-web-server INTERFACE ${OPENSSL_LIBRARIES})
target_link_libraries(simple-web-server INTERFACE OpenSSL::SSL)
target_include_directories(simple-web-server INTERFACE ${OPENSSL_INCLUDE_DIR})
endif()
# If Simple-Web-Server is not a sub-project:
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
add_executable(http_examples http_examples.cpp)
target_link_libraries(http_examples simple-web-server)
find_package(Boost 1.53.0 COMPONENTS system thread filesystem REQUIRED)
target_link_libraries(http_examples ${Boost_LIBRARIES})
target_include_directories(http_examples PRIVATE ${Boost_INCLUDE_DIR})
if(OPENSSL_FOUND)
add_executable(https_examples https_examples.cpp)
target_link_libraries(https_examples simple-web-server)
target_link_libraries(https_examples ${Boost_LIBRARIES})
target_include_directories(https_examples PRIVATE ${Boost_INCLUDE_DIR})
endif()
set(BUILD_TESTING ON)
install(FILES server_http.hpp client_http.hpp server_https.hpp client_https.hpp crypto.hpp utility.hpp status_code.hpp DESTINATION include/simple-web-server)
endif()
if(BUILD_TESTING)
enable_testing()
add_subdirectory(tests)
endif()`
I really don't understand what I'm doing wrong. I've tried to use both the openssl *.a and the *.lib libraries and I had the same result. My OpenSSL version is 1.1.0k and Boost is 1.68.
I also tried to set CMAKE_CXX_FLAGS = -lssl -lcrypto but the output says that ld.exe can't find the libraries. Any help?
Output:
"C:\Program Files\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\MyProjectDesignProject.dir\link.txt --verbose=1
"C:\Program Files\CMake\bin\cmake.exe" -E remove -f CMakeFiles\MyProjectDesignProject.dir/objects.a
C:\MinGw\mingw32\bin\ar.exe cr CMakeFiles\MyProjectDesignProject.dir/objects.a #CMakeFiles\MyProjectDesignProject.dir\objects1.rsp
C:\MinGw\mingw32\bin\g++.exe -Wl,--whole-archive CMakeFiles\MyProjectDesignProject.dir/objects.a -Wl,--no-whole-archive -o MyProjectDesignProject.exe -Wl,--out-implib,libMyProjectDesignProject.dll.a -Wl,--major-image-version,0,--minor-image-version,0 #CMakeFiles\MyProjectDesignProject.dir\linklibs.rsp
CMakeFiles\MyProjectDesignProject.dir/objects.a(main.cpp.obj):main.cpp:(.text$_ZN5boost4asio3ssl6detail17openssl_init_base7do_initD1Ev[__ZN5boost4asio3ssl6detail17openssl_init_base7do_initD1Ev]+0x11): undefined reference to `CONF_modules_unload'
CMakeFiles\MyProjectDesignProject.dir/objects.a(main.cpp.obj):main.cpp:(.text$_ZNK5boost4asio5error6detail12ssl_category7messageB5cxx11Ei[__ZNK5boost4asio5error6detail12ssl_category7messageB5cxx11Ei]+0x11): undefined reference to `ERR_reason_error_string'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text+0x1c0): undefined reference to `OPENSSL_sk_num'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text+0x1da): undefined reference to `OPENSSL_sk_value'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7contextC1ENS1_12context_base6methodE[__ZN5boost4asio3ssl7contextC1ENS1_12context_base6methodE]+0x2b): undefined reference to `ERR_clear_error'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7contextC1ENS1_12context_base6methodE[__ZN5boost4asio3ssl7contextC1ENS1_12context_base6methodE]+0x79): undefined reference to `TLS_method'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7contextC1ENS1_12context_base6methodE[__ZN5boost4asio3ssl7contextC1ENS1_12context_base6methodE]+0x81): undefined reference to `SSL_CTX_new'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7contextC1ENS1_12context_base6methodE[__ZN5boost4asio3ssl7contextC1ENS1_12context_base6methodE]+0xba): undefined reference to `SSL_CTX_ctrl'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7contextC1ENS1_12context_base6methodE[__ZN5boost4asio3ssl7contextC1ENS1_12context_base6methodE]+0xdf): undefined reference to `SSL_CTX_ctrl'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7contextC1ENS1_12context_base6methodE[__ZN5boost4asio3ssl7contextC1ENS1_12context_base6methodE]+0xe9): undefined reference to `TLS_client_method'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7contextC1ENS1_12context_base6methodE[__ZN5boost4asio3ssl7contextC1ENS1_12context_base6methodE]+0xf1): undefined reference to `SSL_CTX_new'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7contextC1ENS1_12context_base6methodE[__ZN5boost4asio3ssl7contextC1ENS1_12context_base6methodE]+0x159): undefined reference to `TLS_server_method'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7contextC1ENS1_12context_base6methodE[__ZN5boost4asio3ssl7contextC1ENS1_12context_base6methodE]+0x161): undefined reference to `SSL_CTX_new'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7contextC1ENS1_12context_base6methodE[__ZN5boost4asio3ssl7contextC1ENS1_12context_base6methodE]+0x1c9): undefined reference to `TLS_method'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7contextC1ENS1_12context_base6methodE[__ZN5boost4asio3ssl7contextC1ENS1_12context_base6methodE]+0x239): undefined reference to `TLS_client_method'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7contextC1ENS1_12context_base6methodE[__ZN5boost4asio3ssl7contextC1ENS1_12context_base6methodE]+0x2a9): undefined reference to `TLS_server_method'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7contextC1ENS1_12context_base6methodE[__ZN5boost4asio3ssl7contextC1ENS1_12context_base6methodE]+0x72e): undefined reference to `ERR_get_error'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7contextD1Ev[__ZN5boost4asio3ssl7contextD1Ev]+0x1f): undefined reference to `SSL_CTX_get_default_passwd_cb_userdata'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7contextD1Ev[__ZN5boost4asio3ssl7contextD1Ev]+0x5a): undefined reference to `SSL_CTX_set_default_passwd_cb_userdata'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7contextD1Ev[__ZN5boost4asio3ssl7contextD1Ev]+0x6f): undefined reference to `SSL_CTX_get_ex_data'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7contextD1Ev[__ZN5boost4asio3ssl7contextD1Ev]+0x8d): undefined reference to `SSL_CTX_get_ex_data'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7contextD1Ev[__ZN5boost4asio3ssl7contextD1Ev]+0xc4): undefined reference to `SSL_CTX_set_ex_data'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7contextD1Ev[__ZN5boost4asio3ssl7contextD1Ev]+0xd1): undefined reference to `SSL_CTX_free'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7context11set_optionsElRNS_6system10error_codeE[__ZN5boost4asio3ssl7context11set_optionsElRNS_6system10error_codeE]+0x19): undefined reference to `SSL_CTX_set_options'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7context15set_verify_modeEiRNS_6system10error_codeE[__ZN5boost4asio3ssl7context15set_verify_modeEiRNS_6system10error_codeE]+0x12): undefined reference to `SSL_CTX_get_verify_callback'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7context15set_verify_modeEiRNS_6system10error_codeE[__ZN5boost4asio3ssl7context15set_verify_modeEiRNS_6system10error_codeE]+0x2c): undefined reference to `SSL_CTX_set_verify'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7context16load_verify_fileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_6system10error_codeE[__ZN5boost4asio3ssl7context16load_verify_fileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_6system10error_codeE]+0xb): undefined reference to `ERR_clear_error'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7context16load_verify_fileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_6system10error_codeE[__ZN5boost4asio3ssl7context16load_verify_fileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_6system10error_codeE]+0x2e): undefined reference to `SSL_CTX_load_verify_locations'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7context16load_verify_fileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_6system10error_codeE[__ZN5boost4asio3ssl7context16load_verify_fileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_6system10error_codeE]+0x44): undefined reference to `ERR_get_error'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7context24set_default_verify_pathsERNS_6system10error_codeE[__ZN5boost4asio3ssl7context24set_default_verify_pathsERNS_6system10error_codeE]+0x18): undefined reference to `SSL_CTX_set_default_verify_paths'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7context24set_default_verify_pathsERNS_6system10error_codeE[__ZN5boost4asio3ssl7context24set_default_verify_pathsERNS_6system10error_codeE]+0x2e): undefined reference to `ERR_get_error'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl7context26use_certificate_chain_fileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_6system10error_codeE[__ZN5boost4asio3ssl7context26use_certificate_chain_fileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_6system10error_codeE]+0xb): undefined reference to `ERR_clear_error'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZNK5boost4asio3ssl20rfc2818_verificationclEbRNS1_14verify_contextE[__ZNK5boost4asio3ssl20rfc2818_verificationclEbRNS1_14verify_contextE]+0x38e): undefined reference to `X509_NAME_ENTRY_get_data'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl6detail6engineC1EP10ssl_ctx_st[__ZN5boost4asio3ssl6detail6engineC1EP10ssl_ctx_st]+0x11): undefined reference to `SSL_new'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl6detail6engineC1EP10ssl_ctx_st[__ZN5boost4asio3ssl6detail6engineC1EP10ssl_ctx_st]+0x2d): undefined reference to `ERR_get_error'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl6detail6engineC1EP10ssl_ctx_st[__ZN5boost4asio3ssl6detail6engineC1EP10ssl_ctx_st]+0x7b): undefined reference to `SSL_ctrl'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl6detail6engineC1EP10ssl_ctx_st[__ZN5boost4asio3ssl6detail6engineC1EP10ssl_ctx_st]+0xa0): undefined reference to `SSL_ctrl'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl6detail6engineC1EP10ssl_ctx_st[__ZN5boost4asio3ssl6detail6engineC1EP10ssl_ctx_st]+0xc5): undefined reference to `SSL_ctrl'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl6detail6engineC1EP10ssl_ctx_st[__ZN5boost4asio3ssl6detail6engineC1EP10ssl_ctx_st]+0xf1): undefined reference to `BIO_new_bio_pair'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl6detail6engineD1Ev[__ZN5boost4asio3ssl6detail6engineD1Ev]+0x38): undefined reference to `SSL_get_ex_data'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl6detail6engineD1Ev[__ZN5boost4asio3ssl6detail6engineD1Ev]+0x64): undefined reference to `SSL_set_ex_data'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl6detail6engineD1Ev[__ZN5boost4asio3ssl6detail6engineD1Ev]+0x72): undefined reference to `BIO_free'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl6detail6engineD1Ev[__ZN5boost4asio3ssl6detail6engineD1Ev]+0x7f): undefined reference to `SSL_free'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl6detail6engine10get_outputERKNS0_14mutable_bufferE[__ZN5boost4asio3ssl6detail6engine10get_outputERKNS0_14mutable_bufferE]+0x30): undefined reference to `BIO_read'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl6detail6engine9put_inputERKNS0_12const_bufferE[__ZN5boost4asio3ssl6detail6engine9put_inputERKNS0_12const_bufferE]+0x30): undefined reference to `BIO_write'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZNK5boost4asio3ssl6detail6engine14map_error_codeERNS_6system10error_codeE[__ZNK5boost4asio3ssl6detail6engine14map_error_codeERNS_6system10error_codeE]+0x62): undefined reference to `BIO_ctrl'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZNK5boost4asio3ssl6detail6engine14map_error_codeERNS_6system10error_codeE[__ZNK5boost4asio3ssl6detail6engine14map_error_codeERNS_6system10error_codeE]+0x8f): undefined reference to `SSL_get_shutdown'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl6detail6engine7performEMS3_FiPvjES4_jRNS_6system10error_codeEPj[__ZN5boost4asio3ssl6detail6engine7performEMS3_FiPvjES4_jRNS_6system10error_codeEPj]+0x13): undefined reference to `BIO_ctrl_pending'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl6detail6engine7performEMS3_FiPvjES4_jRNS_6system10error_codeEPj[__ZN5boost4asio3ssl6detail6engine7performEMS3_FiPvjES4_jRNS_6system10error_codeEPj]+0x1b): undefined reference to `ERR_clear_error'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl6detail6engine7performEMS3_FiPvjES4_jRNS_6system10error_codeEPj[__ZN5boost4asio3ssl6detail6engine7performEMS3_FiPvjES4_jRNS_6system10error_codeEPj]+0x74): undefined reference to `SSL_get_error'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl6detail6engine7performEMS3_FiPvjES4_jRNS_6system10error_codeEPj[__ZN5boost4asio3ssl6detail6engine7performEMS3_FiPvjES4_jRNS_6system10error_codeEPj]+0x8d): undefined reference to `BIO_ctrl_pending'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl6detail6engine9do_acceptEPvj[__ZN5boost4asio3ssl6detail6engine9do_acceptEPvj]+0x12): undefined reference to `SSL_accept'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl6detail6engine10do_connectEPvj[__ZN5boost4asio3ssl6detail6engine10do_connectEPvj]+0x12): undefined reference to `SSL_connect'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl6detail6engine7do_readEPvj[__ZN5boost4asio3ssl6detail6engine7do_readEPvj]+0x30): undefined reference to `SSL_read'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN5boost4asio3ssl6detail6engine8do_writeEPvj[__ZN5boost4asio3ssl6detail6engine8do_writeEPvj]+0x30): undefined reference to `SSL_write'
Plugins/MyProject/libMyProject.a(MyProjectMatch.cpp.obj):MyProjectMatch.cpp:(.text$_ZN9SimpleWeb6ClientIN5boost4asio3ssl6streamINS2_19basic_stream_socketINS2_2ip3tcpEEEEEE9handshakeERKSt10shared_ptrINS_10ClientBaseIS9_E7SessionEE[__ZN9SimpleWeb6ClientIN5boost4asio3ssl6streamINS2_19basic_stream_socketINS2_2ip3tcpEEEEEE9handshakeERKSt10shared_ptrINS_10ClientBaseIS9_E7SessionEE]+0x51): undefined reference to `SSL_ctrl'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [CMakeFiles\MyProjectDesignProject.dir\build.make:115: MyProjectDesignProject.exe] Error 1
make[2]: Leaving directory 'D:/MyProject_Repos/Cpp_Plugin_Repo/cpp-plugin-repo/server-cpp/Build'
make[1]: *** [CMakeFiles\Makefile2:80: CMakeFiles/MyProjectDesignProject.dir/all] Error 2
make[1]: Leaving directory 'D:/MyProject_Repos/Cpp_Plugin_Repo/cpp-plugin-repo/server-cpp/Build'
make: *** [Makefile:86: all] Error 2

Related

net-snmp flags in CMAKE

Before anything, I just want to say I am very new to CMAKE, almost never used it but now forced to...
I am trying to include snmp features in a previous project, using Net-SNMP library. But first, I wrote a minimalistic code just to test my functions. According to the library tutorial, this is how I must compile the code:
First, I must create object file:
gcc -I. `net-snmp-config --cflags` -c -o tfsnmpset.o tfsnmpset.c
Then, I must generate the executable:
gcc -o tfsnmpset tfsnmpset.o `net-snmp-config --libs`
By doing this, the program compiles perfectly and everything is fine.
Now the project in which I want to incorporate that piece of code uses CMakeLists.txt to generate its makefile.
My question is, how do I include the following flags in my CMakeLists.txt?
When creating object files: `net-snmp-config --cflags`
When generating executable: `net-snmp-config --libs`
I actually tried to build a library out of my code that uses Net-SNMP that I could just use in my main project:
cmake_minimum_required(VERSION 3.12)
project(snmp_daemon C)
set(CMAKE_C_STANDARD 99)
SET(CMAKE_C_COMPILER /usr/bin/gcc)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I. `net-snmp-config --cflags`" )
add_library(tfsnmpset tfsnmp.c tfsnmp.h)
add_executable(snmp_daemon main.c ./tfsnmp.h)
target_link_libraries(snmp_daemon tfsnmpset)
The errors:
/media/user/xtra/apps/clion-2018.2.1/bin/cmake/linux/bin/cmake --build /home/fabrice/projects/snmp-daemon/cmake-build-debug --target snmp_daemon -- -j 2
[ 25%] Linking C static library libtfsnmpset.a
[ 50%] Built target tfsnmpset
[ 75%] Linking C executable snmp_daemon
libtfsnmpset.a(tfsnmp.c.o): In function `tfsnmpset':
/home/user/projects/snmp-daemon/tfsnmp.c:121: undefined reference to `snmp_parse_args'
/home/user/projects/snmp-daemon/tfsnmp.c:147: undefined reference to `snmp_get_do_debugging'
/home/user/projects/snmp-daemon/tfsnmp.c:147: undefined reference to `debugmsgtoken'
/home/user/projects/snmp-daemon/tfsnmp.c:147: undefined reference to `debugmsg'
/home/user/projects/snmp-daemon/tfsnmp.c:147: undefined reference to `debugmsgtoken'
/home/user/projects/snmp-daemon/tfsnmp.c:147: undefined reference to `debugmsg'
/home/user/projects/snmp-daemon/tfsnmp.c:194: undefined reference to `snmp_open'
/home/user/projects/snmp-daemon/tfsnmp.c:199: undefined reference to `snmp_sess_perror'
/home/user/projects/snmp-daemon/tfsnmp.c:207: undefined reference to `snmp_pdu_create'
/home/user/projects/snmp-daemon/tfsnmp.c:210: undefined reference to `snmp_parse_oid'
/home/user/projects/snmp-daemon/tfsnmp.c:211: undefined reference to `snmp_perror'
/home/user/projects/snmp-daemon/tfsnmp.c:214: undefined reference to `snmp_add_var'
/home/user/projects/snmp-daemon/tfsnmp.c:216: undefined reference to `snmp_perror'
/home/user/projects/snmp-daemon/tfsnmp.c:222: undefined reference to `snmp_close'
/home/user/projects/snmp-daemon/tfsnmp.c:230: undefined reference to `snmp_synch_response'
/home/user/projects/snmp-daemon/tfsnmp.c:236: undefined reference to `print_variable'
/home/user/projects/snmp-daemon/tfsnmp.c:239: undefined reference to `snmp_errstring'
/home/user/projects/snmp-daemon/tfsnmp.c:247: undefined reference to `fprint_objid'
/home/user/projects/snmp-daemon/tfsnmp.c:257: undefined reference to `snmp_sess_perror'
/home/user/projects/snmp-daemon/tfsnmp.c:262: undefined reference to `snmp_free_pdu'
/home/user/projects/snmp-daemon/tfsnmp.c:263: undefined reference to `snmp_close'
collect2: error: ld returned 1 exit status
CMakeFiles/snmp_daemon.dir/build.make:84: recipe for target 'snmp_daemon' failed
make[3]: *** [snmp_daemon] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/snmp_daemon.dir/all' failed
make[2]: *** [CMakeFiles/snmp_daemon.dir/all] Error 2
CMakeFiles/Makefile2:84: recipe for target 'CMakeFiles/snmp_daemon.dir/rule' failed
make[1]: *** [CMakeFiles/snmp_daemon.dir/rule] Error 2
Makefile:118: recipe for target 'snmp_daemon' failed
make: *** [snmp_daemon] Error 2
You should link to snmp libraries
find_library(NETSNMPAGENT "netsnmpagent")
find_library(NETSNMPMIBS "netsnmpmibs")
find_library(NETSNMP "netsnmp")
target_link_libraries(snmp_daemon tfsnmpset ${NETSNMPAGENT} ${NETSNMPMIBS} ${NETSNMP})

undefined reference to `vtable for boost::detail::thread_data_base'

I've trying to solve this error whole day without result.
Compiling with codeblocks+ mingw + cmake
image
||=== Build: all in otclient (compiler: GNU GCC Compiler) ===|
undefined reference to `vtable for boost::detail::thread_data_base'|
undefined reference to `boost::thread::start_thread_noexcept()'|
undefined reference to `boost::thread::join_noexcept()'|
undefined reference to `boost::detail::thread_data_base::~thread_data_base()'|
undefined reference to `boost::detail::thread_data_base::~thread_data_base()'|
||error: ld returned 1 exit status|
CMakeFiles\otclient.dir\build.make|2272|recipe for target 'otclient.exe' failed|
CMakeFiles\Makefile2|71|recipe for target 'CMakeFiles/otclient.dir/all' failed|
C:\Users\Tomek\Desktop\compile\Makefile|128|recipe for target 'all' failed|
||=== Build failed: 9 error(s), 0 warning(s) (8 minute(s), 25 second(s)) ===|
My cmakeLists:
cmake_minimum_required(VERSION 3.6)
project(otclient)
set(VERSION "0.6.6")
option(FRAMEWORK_SOUND "Use SOUND " ON)
option(FRAMEWORK_GRAPHICS "Use GRAPHICS " ON)
option(FRAMEWORK_XML "Use XML " ON)
option(FRAMEWORK_NET "Use NET " ON)
option(FRAMEWORK_SQL "Use SQL" OFF)
include(src/framework/CMakeLists.txt)
include(src/client/CMakeLists.txt)
# functions map for reading backtraces
if(NOT APPLE)
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -Wl,-Map=${PROJECT_NAME}.map")
endif()
option(USE_PCH "Use precompiled header (speed up compile)" OFF)
set(executable_SOURCES
src/main.cpp
)
# add executable icon for win32 platforms
if(WIN32)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/otcicon.o
COMMAND ${CMAKE_RC_COMPILER}
-I${CMAKE_CURRENT_SOURCE_DIR}/src
-i${CMAKE_CURRENT_SOURCE_DIR}/src/otcicon.rc
-o ${CMAKE_CURRENT_BINARY_DIR}/otcicon.o)
set(executable_SOURCES ${executable_SOURCES} otcicon.o)
endif()
if(MINGW)
add_definitions(-DWIN32)
endif()
add_definitions(-D"VERSION=\\"${VERSION}\\"")
# add client executable
set(CMAKE_CXX_STANDARD 11)
find_package(Boost COMPONENTS thread system REQUIRED)
include_directories(${Boost_INCLUDE_DIR})
add_executable(${PROJECT_NAME} ${framework_SOURCES} ${client_SOURCES} ${executable_SOURCES})
target_link_libraries(${PROJECT_NAME} ${framework_LIBRARIES} ${Boost_LIBRARIES})
target_include_directories(${PROJECT_NAME} PRIVATE ${Boost_INCLUDE_DIRS})
if(USE_PCH)
include(cotire)
cotire(${PROJECT_NAME})
message(STATUS "Use precompiled header: ON")
else()
message(STATUS "Use precompiled header: OFF")
endif()
# installation
set(DATA_INSTALL_DIR share/${PROJECT_NAME})
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
install(FILES README.md BUGS LICENSE AUTHORS init.lua ${PROJECT_NAME}rc.lua DESTINATION ${DATA_INSTALL_DIR})
install(DIRECTORY data modules DESTINATION ${DATA_INSTALL_DIR} PATTERN ".git" EXCLUDE)
# add "make run"
add_custom_target(run COMMAND ${PROJECT_NAME} DEPENDS ${PROJECT_NAME} WORKING_DIRECTORY ${CMAKE_PROJECT_DIR})
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)

undefined reference to symbol '_ZN5boost6system15system_categoryEv' /

this is not the first time I meet this error, but [previous solution][1] doesn't make sense.
[100%] Linking CXX executable ../bin/qttest
/usr/bin/x86_64-linux-gnu-ld: CMakeFiles/qttest.dir/src/main.cpp.o:
undefined reference to symbol '_ZN5boost6system15system_categoryEv'
/usr/lib/x86_64-linux-gnu/libboost_system.so: error adding symbols:
DSO missing from command line collect2: error: ld returned 1 exit
status
here is my cmakelists
cmake_minimum_required(VERSION 2.4.6)
set(OpenCV_DIR "/usr/local/opencv-2.4.9/share/OpenCV")
include_directories("/usr/local/opencv-2.4.9/include")
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
find_package(Qt4 COMPONENTS QtCore QtGui)
find_package(OpenCV 2.4.9 REQUIRED)
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
rosbuild_init()
rosbuild_genmsg()
find_package(Boost COMPONENTS system REQUIRED)
set(qt_srcs
src/mainwindow.cpp
src/listnerthr.cpp
src/ros_thr.cpp
src/CreatDataBuffer.cpp
src/CreatBuffer.cpp
src/pid_controller.cpp
src/low_pass_filter.cpp
src/plot_publisher.cpp)
set(qt_hdrs
src/mainwindow.h
src/listnerthr.h
src/ros_thr.h
src/CreatDataBuffer.h
src/HelperFunctions.h
src/CreatBuffer.h
src/pid_controller.h
src/low_pass_filter.h
src/plot_publisher.h)
qt4_automoc(${qt_srcs})
QT4_WRAP_CPP(qt_moc_srcs ${qt_hdrs})
QT4_WRAP_UI(uis_h src/mainwindow.ui)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
rosbuild_add_executable(qttest src/main.cpp
${uis_h} ${qt_srcs} ${qt_moc_srcs})
target_link_libraries(qttest ${QT_LIBRARIES}${Boost_LIBARAIES }${OpenCV_LIBARAIES})
any clues would be appreciated.
I got another problem after changing the cmakelists
*** No rule to make target '/usr/lib/x86_64-linux-gnu/libboost_system.so/usr/lib/x86_64-linux-gnu/libboost_system.so', needed by '../bin/qttest'. Stop. CMakeFiles/Makefile2:425: recipe for target 'CMakeFiles/qttest.dir/all' failed –
You should pass boost libraries to the target_link_libraries command. The smallest change to your file will be as follows:
target_link_libraries(qttest ${QT_LIBRARIES} ${LIBS})
But since you are using find_package for Boost and you do not actually use your LIBS variable anywhere, you should stick with something like this:
find_package(Boost COMPONENTS system REQUIRED)
...
target_link_libraries(qttest ${QT_LIBRARIES} ${OpenCV_LIBS} ${Boost_LIBRARIES})
And remove LIBS altogether.

SuperLU with OpenBLAS: undefined reference to `pthread_atfork'

When compiling the SuperLU 4.3 library using OpenBLAS instead of regular BLAS distributions, this error keeps coming up:
>gcc cdrive.o sp_cconvert.o cgst01.o cgst02.o cgst04.o cgst07.o sp_ienv.o \
> libtmglib.a /a/location/lib/libsuperlu_4.3.a ->L/a/location/lib/libopenblas.a -lopenblas -lm -o ctest
>/a/location/lib/libopenblas.a(memory.o): In function >'openblas_fork_handler':
>memory.c:(.text+0x3e0): undefined reference to 'pthread_atfork'
>/a/location/lib/libopenblas.a(blas_server.o): In function >'blas_thread_shutdown_':
>blas_server.c:(.text+0x25e): undefined reference to 'pthread_join'
>/a/location/lib/libopenblas.a(blas_server.o): In function >'goto_set_num_threads':
>blas_server.c:(.text+0x403): undefined reference to 'pthread_create'
>/a/location/lib/libopenblas.a(blas_server.o): In function >'blas_thread_init':
>blas_server.c:(.text+0x721): undefined reference to 'pthread_create'
You need to link pthread / libpthread. Depending on the linker, this might be done automatically, but not in your case.

Point Cloud Library(PCL) compile issues UBUNTU 12.04 - undefined reference to symbol '_ZN5boost6system15system_categoryEv'

I'm getting this error when i try to run "pcl pcl_write.cpp". The cpp file is just a test program to check if pcl is working. (Also, alias pcl = ~/.compile.sh ).
arun#Arun:~/pcl_projects/testing_pcl$ pcl pcl_write.cpp
/usr/bin/ld: /tmp/ccQOUJZ2.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv'
/usr/bin/ld: note: '_ZN5boost6system15system_categoryEv' is defined in DSO
/usr/lib/libboost_system.so.1.46.1 so try adding it to the linker command line
/usr/lib/libboost_system.so.1.46.1: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
NOTE:
.compile.sh contains the below line :
g++ -ggdb -I/usr/lib -I/usr/include/pcl-1.7 -I/usr/include/eigen3 -o `basename $1 .cpp`
$1 `pkg-config --libs pcl_apps-1.7 pcl_common-1.7 pcl_features-1.7
pcl_filters-1.7 pcl_geometry-1.7 pcl_io-1.7 pcl_kdtree-1.7 pcl_keypoints-1.7
pcl_registration-1.7 pcl_sample_consensus-1.7 pcl_search-1.7 pcl_segmentation-1.7
pcl_surface-1.7 pcl_tracking-1.7 pcl_visualization-1.7 flann`;
Note : I'm able to compile using CMAKE!
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(pcl_write)
find_package(PCL 1.7 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable (pcl_write pcl_write.cpp)
target_link_libraries (pcl_write ${PCL_LIBRARIES})

Resources