我正在尝试安装一个软件,它使用cmake来安装自己,当我在commandlin cmake上给.. 它让我在这个文件中出现以下错误,CMakeLists.txt -------- line ---> 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'
答案 0 :(得分:147)
我有同样的问题(openssl),这对我来说在Ubuntu 14.04.1 LTS
sudo apt-get install libssl-dev
答案 1 :(得分:55)
这是一个常见的误解:CMake不需要环境变量来知道库和包含dir的位置只是CMake变量。
由于CMake无法找到您的OpenSSL lib和include目录,因此在调用它时,您必须手动告诉他们命令行的位置。使用选项-D
从命令行设置CMake中的常量。您需要设置常量OPENSSL_ROOT_DIR
和OPENSSL_LIBRARIES
,因为它们是触发错误的常量。
cmake -DOPENSSL_ROOT_DIR=/usr/local/ssl -DOPENSSL_LIBRARIES=/usr/local/ssl/lib
答案 2 :(得分:17)
使用
将其修复到macOS上brew install openssl
cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib
答案 3 :(得分:16)
请从以下链接安装openssl:
https://code.google.com/p/openssl-for-windows/downloads/list
然后设置以下变量:
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
答案 4 :(得分:12)
如果您正在使用Ubuntu,请运行sudo apt install libssl-dev
。
答案 5 :(得分:10)
sudo apt install libssl-dev
适用于Ubuntu 18.04。
答案 6 :(得分:9)
如果您可以使用 pkg-config :pkg_search_module()
可以为您找到OpenSSL。
# 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})
答案 7 :(得分:8)
同样的问题,并使用以下命令在我的centos 6.5上修复它。
yum install openssl-devel
答案 8 :(得分:4)
你在cmake模块中有FindOpenSSL.cmake文件(路径usr / shared.cmake-3.5 / modules) #搜索OpenSSL
x
答案 9 :(得分:3)
正如其他人提到的,在 Ubuntu 上你应该运行
sudo apt install libssl-dev
但对我来说这还不够,因为虽然安装了构建所需的库,但仍然无法找到它们。我必须另外安装的是
sudo apt install pkg-config
答案 10 :(得分:2)
仅仅是为了解决OP问题的替代工作答案:
cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/ -DOPENSSL_CRYPTO_LIBRARY=/usr/local/opt/openssl/lib/
答案 11 :(得分:1)
@Morwenn是对的。
您需要配置openssl DIR。
在此之前,您可能需要确保拥有它。
你应该检查一下你是否拥有它。
首先运行openssl version
,然后如果你拥有它,你可以win + r
运行openssl
并且你赢了找到核心目录,因为它可能不会在你的系统中命名为openssl。
答案 12 :(得分:1)
Fedora 27用户请注意:我必须安装openssl-devel
包才能成功运行cmake
。
sudo dnf install openssl-devel
答案 13 :(得分:0)
以防万一...这对我有用。很抱歉使用特定版本的OpenSSL,但可能是理想的。
# On macOS, search Homebrew for keg-only versions of OpenSSL
# equivalent of # -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/ -DOPENSSL_CRYPTO_LIBRARY=/usr/local/opt/openssl/lib/
if (CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin")
execute_process(
COMMAND brew --prefix OpenSSL
RESULT_VARIABLE BREW_OPENSSL
OUTPUT_VARIABLE BREW_OPENSSL_PREFIX
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (BREW_OPENSSL EQUAL 0 AND EXISTS "${BREW_OPENSSL_PREFIX}")
message(STATUS "Found OpenSSL keg installed by Homebrew at ${BREW_OPENSSL_PREFIX}")
set(OPENSSL_ROOT_DIR "${BREW_OPENSSL_PREFIX}/")
set(OPENSSL_INCLUDE_DIR "${BREW_OPENSSL_PREFIX}/include")
set(OPENSSL_LIBRARIES "${BREW_OPENSSL_PREFIX}/lib")
set(OPENSSL_CRYPTO_LIBRARY "${BREW_OPENSSL_PREFIX}/lib/libcrypto.dylib")
endif()
endif()
...
find_package(OpenSSL REQUIRED)
if (OPENSSL_FOUND)
# Add the include directories for compiling
target_include_directories(${TARGET_SERVER} PUBLIC ${OPENSSL_INCLUDE_DIR})
# Add the static lib for linking
target_link_libraries(${TARGET_SERVER} OpenSSL::SSL OpenSSL::Crypto)
message(STATUS "Found OpenSSL ${OPENSSL_VERSION}")
else()
message(STATUS "OpenSSL Not Found")
endif()
答案 14 :(得分:0)
答案实际上取决于您的系统状态和您使用 cmake
的程序。根据您遇到的第二个错误,您可能需要一个额外的 openssl
软件包,该软件包当前未安装在您的系统上。您可以使用 aptitude search
命令搜索包。我建议搜索“ssl”而不是“openssl”,因为包有时不包含“open”这个词。
检查要安装哪些软件包的另一件事是查看您正在安装的产品的手册或文档是否包含有关要安装哪些软件包的信息。
与其他帖子的评论一样,其中一个包是 libssl-dev,但您的程序可能还需要其他一些包。
答案 15 :(得分:-1)
这是我在CMakeList.txt
(有效)中添加的内容:
# https://cmake.org/cmake/help/latest/command/find_package.html
# in the above link, it states:
# "In Module mode, CMake searches for a file called Find<PackageName>.cmake.
# The file is first searched in the CMAKE_MODULE_PATH, then among the Find
# Modules provided by the CMake installation. If the file is found, it is
# read and processed by CMake. It is responsible for finding the package,
# checking the version, and producing any needed messages. Some find-modules
# provide limited or no support for versioning; check the module documentation."
#
# FindOpenSSL.cmake can be found in path/to/cmake/Modules
#
# https://cmake.org/cmake/help/latest/module/FindOpenSSL.html
#
find_package(OpenSSL REQUIRED)
if (OPENSSL_FOUND)
# Add the include directories for compiling
target_include_directories(${PROJECT_NAME} PUBLIC ${OPENSSL_INCLUDE_DIR})
# Add the static lib for linking
target_link_libraries(${PROJECT_NAME} OpenSSL::SSL OpenSSL::Crypto)
message(STATUS "Found OpenSSL ${OPENSSL_VERSION}")
else()
message(STATUS "OpenSSL Not Found")
endif()