cmake无法findopenssl
我试图安装一个软件,它使用cmake来安装自己,当我在commandlin cmake ..
它给了我下面的错误在这个文件中,CMakeLists.txt ——–线—> find_package(OpenSSL REQUIRED): –
cmake .. -- Could NOT find Git (missing: GIT_EXECUTABLE) ZLib include dirs: /usr/include ZLib libraries: /usr/lib/arm-linux-gnueabihf/libz.so Compiling with SSL support CMake Error at /usr/local/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:97 (message): Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_LIBRARIES OPENSSL_INCLUDE_DIR) Call Stack (most recent call first): /usr/local/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:291 (_FPHSA_FAILURE_MESSAGE) /usr/local/share/cmake-2.8/Modules/FindOpenSSL.cmake:313 (find_package_handle_standard_args) CMakeLists.txt:436 (find_package)
这里是文件CMakeLists.txt的一部分,错误在哪里:——
# # OpenSSL # if (WITH_SSL) message("Compiling with SSL support") if (USE_CYASSL) # Use CyaSSL as OpenSSL replacement. # TODO: Add a find_package command for this also. message("CyaSSL include dir: ${CYASSL_INCLUDE_DIRS}") message("CyaSSL libraries: ${CYASSL_LIB}") # Additional to the root directory we need to include # the cyassl/ subdirectory which contains the OpenSSL # compatability layer headers. foreach(inc ${CYASSL_INCLUDE_DIRS}) include_directories(${inc} ${inc}/cyassl) endforeach() list(APPEND LIB_LIST ${CYASSL_LIB}) else() # TODO: Add support for STATIC also. find_package(OpenSSL REQUIRED) message("OpenSSL include dir: ${OPENSSL_INCLUDE_DIR}") message("OpenSSL libraries: ${OPENSSL_LIBRARIES}") include_directories(${OPENSSL_INCLUDE_DIR}) list(APPEND LIB_LIST ${OPENSSL_LIBRARIES}) endif() endif(WITH_SSL)
http://www.opensource.apple.com/source/OpenSSL/OpenSSL-7.1/openssl/INSTALL?txt
现在我已经安装了Openssl,在这里:—-
ssl header is here -- > /usr/local/ssl/include/openssl/ ssl library is here -- > /usr/local/ssl/lib/libssl.a /usr/local/ssl/lib/libcrypto.a openssl is here -- > /usr/local/ssl/bin
我已经把我的.profile设置为:—-
export LD_LIBRARY_PATH=/usr/local/ssl/include/openssl:/usr/lib:/usr/local/lib:/usr/lib/pkgconfig:/usr/local/include/wx-2.8/wx:$LD_LIBRARY_PATH export PKG_CONFIG_PATH=/usr/lib/pkgconfig export OPENSSL_ROOT_DIR=/usr/local/ssl export OPENSSL_LIBRARIES=/usr/local/ssl/lib/ PATH = /usr/local/ssl/bin:$PATH
如何解决这个错误?
编辑: –
得到这个错误
/usr/local/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup': dso_dlfcn.c:(.text+0x10): undefined reference to `dlopen' dso_dlfcn.c:(.text+0x24): undefined reference to `dlsym' dso_dlfcn.c:(.text+0x30): undefined reference to `dlclose'
这是一个常见的误解:CMake并不需要环境variables来知道库和dir包含的是CMakevariables。
由于CMake找不到你的OpenSSL库和包含目录,所以当你调用它的时候,你将不得不手动告诉他它的命令行。 使用选项-D
从命令行设置CMake中的常量。 您将需要设置常量OPENSSL_ROOT_DIR
和OPENSSL_LIBRARIES
因为它们是触发错误的一个。
cmake -DOPENSSL_ROOT_DIR=/usr/local/ssl -DOPENSSL_LIBRARIES=/usr/local/ssl/lib
我有同样的问题(openssl),这在Ubuntu 14.04.1 LTS上为我工作
sudo apt-get install libssl-dev
用macOS修复它
brew install openssl cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib
请从下面的链接安装openssl:
https://code.google.com/p/openssl-for-windows/downloads/list
然后设置下面的variables:
OPENSSL_ROOT_DIR=D:/softwares/visualStudio/openssl-0.9.8k_WIN32 OPENSSL_INCLUDE_DIR=D:/softwares/visualStudio/openssl-0.9.8k_WIN32/include OPENSSL_LIBRARIES=D:/softwares/visualStudio/openssl-0.9.8k_WIN32/lib
同样的问题,并使用以下命令将其固定在我的centos 6.5上。
yum install openssl-devel
如果你可以使用pkg-config : pkg_search_module()
可以为你findOpenSSL。
# Search OpenSSL find_package(PkgConfig REQUIRED) pkg_search_module(OPENSSL REQUIRED openssl) if( OPENSSL_FOUND ) include_directories(${OPENSSL_INCLUDE_DIRS}) message(STATUS "Using OpenSSL ${OPENSSL_VERSION}") else() # Error; with REQUIRED, pkg_search_module() will throw an error by it's own endif() target_link_libraries(${YOUR_TARGET_HERE} ${OPENSSL_LIBRARIES})
你正在cmake模块中findFindOpenSSL.cmake文件(pathusr / shared.cmake-3.5 / modules)#searchOpenSSL
find_package(OpenSSL REQUIRED) if( OpenSSL_FOUND ) include_directories(${OPENSSL_INCLUDE_DIRS}) link_directories(${OPENSSL_LIBRARIES}) message(STATUS "Using OpenSSL ${OPENSSL_VERSION}") target_link_libraries(project_name /path/of/libssl.so /path/of/libcrypto.so)
@Morwenn是对的。 你需要configurationopenssl DIR。 在此之前,你可能需要确保你有它。 你应该检查你是否有。 首先运行openssl version
,如果你有它,你可以win + r
运行openssl
,你赢了find核心目录,因为它可能不会在你的系统中命名为openssl。