cmake在Windows上找不到openssl [英] cmake can not find openssl on windows

查看:1791
本文介绍了cmake在Windows上找不到openssl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了这篇文章,但没有回答我的问题:( cmake无法执行找到openssl )

I already read this post and it did not answer my questions: (cmake not able to find openssl)

我正在Windows 10 64位环境中工作,并且我想使用带有ssl支持的boost asio,因此我在C:\ Local \ OpenSSL-Win64中安装了openssl,并且有一个指向此的环境变量.

I am working in windows 10 64 bit and I want to use boost asio with ssl support, so I installed openssl in C:\Local\OpenSSL-Win64 and I have a environment variable pointing to this.

我在cmake中有以下代码:

I have this code in cmake:

file(TO_CMAKE_PATH $ENV{OPENSSL_ROOT} OPENSSL_ROOT_DIR)
message(WARNING "root: ${OPENSSL_ROOT_DIR}")
find_package(OpenSSL )

message(WARNING "OpenSSL_VERSION: ${OPENSSL_VERSION}")
message(WARNING "OpenSSL_INCLUDE_DIR: ${OPENSSL_INCLUDE_DIR}")
message(WARNING "OpenSSL_LIBRARIES: ${OPENSSL_LIBRARIES}")

当我运行cmake时,我收到以下消息:

and when I run the cmake, I am getting this message:

CMake Warning at CMakeLists.txt:44 (message):
  root: C:/Local/OpenSSL-Win64


CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/FindOpenSSL.cmake:293 (list):
  list GET given empty list
Call Stack (most recent call first):
  CMakeLists.txt:45 (find_package)


CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/FindOpenSSL.cmake:294 (list):
  list GET given empty list
Call Stack (most recent call first):
  CMakeLists.txt:45 (find_package)


CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/FindOpenSSL.cmake:296 (list):
  list GET given empty list
Call Stack (most recent call first):
  CMakeLists.txt:45 (find_package)


CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/FindOpenSSL.cmake:298 (list):
  list GET given empty list
Call Stack (most recent call first):
  CMakeLists.txt:45 (find_package)


Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing:  OPENSSL_LIBRARIES) (found version ".0.0`")
CMake Warning at CMakeLists.txt:47 (message):
  OpenSSL_VERSION: .0.0`


CMake Warning at CMakeLists.txt:48 (message):
  OpenSSL_INCLUDE_DIR: C:/Local/OpenSSL-Win64/include


CMake Warning at CMakeLists.txt:49 (message):
  OpenSSL_LIBRARIES: SSL_EAY_LIBRARY-NOTFOUND;LIB_EAY_LIBRARY-NOTFOUND

可以看到cmake可以找到正确指向C:/Local/OpenSSL-Win64的环境变量

as it can be seen the cmake could find the environment variable which is correctly pointed to C:/Local/OpenSSL-Win64

同样有趣的是,它可以找到包含路径:

also interestingly, it can find the include path:

CMake Warning at CMakeLists.txt:48 (message):
OpenSSL_INCLUDE_DIR: C:/Local/OpenSSL-Win64/include

但是版本和包含库不正确.

but the version, and include library is not right.

我是否可以强制cmake找到openssl的任何特定方法?

is there any specific ways that I can force cmake to find the openssl?

我如何确保它找到合适的静态库?

How can I make sure that it finds the suitable static library?

Aftre升级到cmake 3.8,现在,cmake可以找到openssl,但找不到其库.输出如下:

Aftre upgrading to cmake 3.8, now, cmake can find openssl, but not its libraries. The output is as follow:

Found OpenSSL: C:/Local/OpenSSL-Win64/lib/libssl.lib (found version "1.1.0e") 
CMake Warning at CMakeLists.txt:52 (message):
  OpenSSL_VERSION: 1.1.0e


CMake Warning at CMakeLists.txt:53 (message):
  OpenSSL_INCLUDE_DIR: C:/Local/OpenSSL-Win64/include


CMake Warning at CMakeLists.txt:54 (message):
  OpenSSL_LIBRARIES:

为什么找不到库?

之所以找不到库,是因为我在不同的情况下使用了变量名.正确的名称是OPENSSL_LIBRARIES.

The reason that it could not find library was that I used the variable name with a different case. The correct name is OPENSSL_LIBRARIES.

有关更多信息,请阅读cmake发行版中的findopenssl.cmake文件.

For more information read the findopenssl.cmake file as part of the cmake distribution.

推荐答案

较新的OpenSSL版本(我认为是1.1.x系列)稍微改变了在opensslv.h标头中指定版本号的格式.这导致其FindOpenSSL.cmake模块中CMake的版本解析代码失败,然后围绕CMake 3.5.0进行了修复.此外,从OpenSSL 1.1.0开始,Windows上的库名称更接近于Unix上的库名称,并分别命名为libcrypto和libssl(可能带有更多后缀),而不是旧名称libeay32和ssleay32. CMake 3.7.0包含此库名称更改的更新.由于这两个更改和修复,如果要对CMake项目使用OpenSSL 1.1.0或更高版本,则可能应该使用CMake 3.7.0或更高版本.

More recent OpenSSL versions (the 1.1.x series I think) slightly changed the formatting of how the version number was specified in the opensslv.h header. This caused CMake's version parsing code in its FindOpenSSL.cmake module to fail, which was then fixed around CMake 3.5.0. Furthermore, from OpenSSL 1.1.0, the library names on Windows are closer to their Unix counterparts and are named libcrypto and libssl (possibly with further suffixes) instead of the old names libeay32 and ssleay32. CMake 3.7.0 contained the update to account for this library name change. As a result of these two changes and fixes, if you want to use OpenSSL 1.1.0 or later with a CMake project, you should probably be using CMake 3.7.0 or later.

这篇关于cmake在Windows上找不到openssl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆