Bedirhan Ateş
Bedirhan Ateş

Reputation: 37

CMake Error: fatal error: openssl/core_names.h: No such file or directory

I have cmake project which uses openssl for TLS, I have installed openssl into my system with

yum install openssl-devel

find_package(OpenSSL REQUIRED)
if (OPENSSL_FOUND)
message(STATUS "Found OpenSSL ${OPENSSL_VERSION}")
else()
message(STATUS "OpenSSL Not Found")
endif()

I got following message:

-- Found OpenSSL 1.0.2s

However, I got following error when I include openssl header file in my project

fatal error: openssl/core_names.h: No such file or directory

How can I resolve this error?

Upvotes: 0

Views: 3229

Answers (2)

Pierwiastek
Pierwiastek

Reputation: 165

I guess you might forget to add the following in your CMakeLists.txt

target_link_libraries(your_executable
    PRIVATE
        openssl

It does populate include directories of your target with path to include folder of openssl library, so the header can be found. You can check if this is your problem by adding

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

this will generate compile_commands.json file into your build folder, which contains build commands - please check if include folder of openssl library is passed as -I argument to your compiler (I assume you are using GCC, so -I argument passes include search paths

Upvotes: 0

arrowd
arrowd

Reputation: 34391

This header seems to be added in OpenSSL 3, according to this man.

Searching for the file in the OpenSSL 1.0.2s tree yields nothing.

Upvotes: 1

Related Questions