Skip to content
Advertisement

Unable to link openssl libraries to CLion C++ program

I have a CLion project. Here is my CMakeLists.txt:

cmake_minimum_required(VERSION 3.3)
project(Project)

> set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
> include_directories(/usr/include/openssl/) 
> link_libraries(openssl)
> set(SOURCE_FILES main.cpp Includes.h b.cpp b.h a.cpp
> a.h) add_executable(Project ${SOURCE_FILES})

And here is error that I get:

[ 25%] Linking CXX executable Project /usr/bin/ld: cannot find -lopenssl
collect2: error: ld returned 1 exit status

Advertisement

Answer

Maybe you should try link_libraries(ssl) instead of link_libraries(openssl), if you’re sure of openssl installed on your local machine. See https://wiki.openssl.org/index.php/Libcrypto_API , it says that “OpenSSL provides two primary libraries: libssl and libcrypto.”.

To fix your issue just add to your CMakeList.txt:

link_libraries(crypto)
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement