Search code examples
c++cmakeopenssllibcrypto

Cmake can't find "openssl" "libcrypto" with pkg_search_module


I'm building a project and in the CMakeLists.txt there are a few pkg_search_module statements, including two for openssl and libcrypto which throw errors in the build process.

pkg_search_module(LIBXML2 libxml-2.0 REQUIRED)
include_directories(${LIBXML2_INCLUDE_DIRS})

pkg_search_module(OPENSSL openssl REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIRS})

pkg_search_module(CONFIG libconfig REQUIRED)
include_directories(${CONFIG_INCLUDE_DIRS})

pkg_search_module(CRYPTO libcrypto REQUIRED)
include_directories(${CRYPTO_INCLUDE_DIRS})

I have these packages installed using apt-get and the way I understand it's possible to give CMake the location of the library if it can't find it, but I'm not sure how to locate them.

I get this output on the terminal:

CMake Error at /usr/share/cmake-3.5/Modules/FindPkgConfig.cmake:578 (message):
   None of the required 'openssl' found
Call Stack (most recent call first):
  /home/openair3/openair-cn/build/CMakeLists.txt:814 (pkg_search_module)
  CMakeLists.txt:41 (include)


CMake Error at /usr/share/cmake-3.5/Modules/FindPkgConfig.cmake:578 (message):
  None of the required 'libcrypto' found
Call Stack (most recent call first):
  /home/openair3/openair-cn/build/CMakeLists.txt:820 (pkg_search_module)
  CMakeLists.txt:41 (include)

I'm using Ubuntu 16.04 on a virtual machine.

I appreciate your advice.


Solution

  • Use dpkg -L <packagename> to see where your packages are installed.

    To install libcrypto, use sudo apt-get install libssl-dev.

    I hope this helps.