When I was building Hadoop 3.3.0 on Windows 10, I hit one error about OpenSSL:
CMake Error at C:/Program Files/CMake/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:165 (message): Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR)
This error was raised by the following line in CMakeLists.txt:
The following is my environment setup:
-- Building for: Visual Studio 16 2019 -- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363. -- The C compiler identification is MSVC 19.26.28806.0 -- The CXX compiler identification is MSVC 19.26.28806.0
CMake version is 3.18.0.
C:\hdp\cmaketest>cmake --version cmake version 3.18.0 CMake suite maintained and supported by Kitware (kitware.com/cmake).
Microsoft Visual C++ version
OpenSSL is installed on Windows using Microsoft vcpkg (a package manager for C++). The version installed in OpenSSL 1.1.18.
C:\hdp\cmaketest>openssl version OpenSSL 1.1.1g 21 Apr 2020
Reproduce the issue
Follow the steps below can reproduce this issue.
- Create project folder C:\hdp\cmaketest
- Create file CMakeLists.txt in the project folder with the following content:
cmake_minimum_required(VERSION 3.10) # set the project name project(Test) # Find package find_package(OpenSSL REQUIRED)
- Run CMake command:
cmake .The error will occur as the following screenshot shows:
Fix this issue
In my system, OpenSSL is installed via vcpkg and installation folder is: C:/vcpkg/installed/x64-windows-static.
Thus to fix this issue, I just need to change the command line to the following:
cmake . -DOPENSSL_ROOT_DIR="C:/vcpkg/installed/x64-windows-static"
The above command line tells CMake that OpenSSL root folder is in the above directory. If you OpenSSL is installed with different triplet or location, please update the command line accordingly.