1

When trying to compile code (using cmake), I keep getting this error :

In file included from /usr/local/include/cpprest/http_client.h:68:
In file included from /usr/local/include/boost/asio/ssl.hpp:18:
In file included from /usr/local/include/boost/asio/ssl/context.hpp:23:
In file included from /usr/local/include/boost/asio/ssl/context_base.hpp:19:
/usr/local/include/boost/asio/ssl/detail/openssl_types.hpp:23:10: fatal error: 'openssl/conf.h' file not found
#include <openssl/conf.h>
         ^~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/httpclient.dir/http_client.cpp.o] Error 1
make[1]: *** [CMakeFiles/httpclient.dir/all] Error 2
make: *** [all] Error 2

I have tried to follow these links but nothing helps : Fatal Error: 'openssl/conf.h' file not found and 'openssl/conf.h' file not found error on on MacOS Big Sur and 'openssl/conf.h' file not found error on MacOS Sierra

Following is my cmake :

cmake_minimum_required(VERSION 3.9)

find_package(cpprestsdk REQUIRED)

set (CMAKE_CXX_STANDARD 11)

add_executable(httpclient http_client.cpp)

set(OPENSSL_ROOT_DIR /usr/local/opt/openssl@3)
#set(OPENSSL_LIBRARIES /usr/local/opt/openssl@3/lib)
set(OPENSSL_ROOT_DIR /usr/local/opt/openssl@3/*)
set(OPENSSL_LIBRARIES /usr/local/opt/openssl@3/lib)
include(FindOpenSSL)

target_include_directories(httpclient INTERFACE ${OPENSSL_ROOT_DIR}/include)

target_link_libraries(httpclient PRIVATE cpprestsdk::cpprest
                                         openssl)

I have also tried setting LDFLAGS and CPPFLAGS, it din't help. Also tried re-installing boost - din't work.

Please help me understand how to resolve this.

Thanks!

0 Answers0