CMake Build Error - Could not Find OpenSSL on Windows 10
insights Stats
Background
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:
find_package(OpenSSL REQUIRED)
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
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
MSVC 19.26.28806.0
OpenSSL 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.
Reference
person ziyu access_time 2 years ago
I download vcpkg,and install openssl.but it still got error. And I build with -X,here is the error message:
Execute:Java13CommandLauncher: Executing 'cmake' with arguments:
'C:\code\hadoop-compile\hadoop-hdfs-project\hadoop-hdfs-native-client/src/'
'-DGENERATED_JAVAH=C:\code\hadoop-compile\hadoop-hdfs-project\hadoop-hdfs-native-client\target/native/javah'
'-DJVM_ARCH_DATA_MODEL=64'
'-DHADOOP_BUILD=1'
'-DREQUIRE_FUSE=false'
'-DREQUIRE_VALGRIND=false'
'-A'
'x64'
The ' characters around the executable and arguments are
not part of the command.
[exec] CMake Warning (dev) in CMakeLists.txt:
[exec] No project() command is present. The top-level CMakeLists.txt file must
[exec] contain a li-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19043.
[exec] teral, direct call to the project() command. Add a line of
[exec] code such as
[exec]
[exec] project(ProjectName)
I download vcpkg,and install openssl.but it still got error. And I build with -X,here is the error message:
Execute:Java13CommandLauncher: Executing 'cmake' with arguments:
'C:\code\hadoop-compile\hadoop-hdfs-project\hadoop-hdfs-native-client/src/'
'-DGENERATED_JAVAH=C:\code\hadoop-compile\hadoop-hdfs-project\hadoop-hdfs-native-client\target/native/javah'
'-DJVM_ARCH_DATA_MODEL=64'
'-DHADOOP_BUILD=1'
'-DREQUIRE_FUSE=false'
'-DREQUIRE_VALGRIND=false'
'-A'
'x64'
The ' characters around the executable and arguments are
not part of the command.
[exec] CMake Warning (dev) in CMakeLists.txt:
[exec] No project() command is present. The top-level CMakeLists.txt file must
[exec] contain a li-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19043.
[exec] teral, direct call to the project() command. Add a line of
[exec] code such as
[exec]
[exec] project(ProjectName)
person Raymond access_time 2 years ago
Try install vcpkg and use it to install the dependent lib like OpenSSL.
https://kontext.tech/article/594/microsoft-vcpkg-c-library-manager
If it still doesn’t work, you need use maven debug mode (-X) to see if your maven command has parameters about cmake prefix path or OpenSSL path.
Try install vcpkg and use it to install the dependent lib like OpenSSL.
https://kontext.tech/article/594/microsoft-vcpkg-c-library-manager
If it still doesn’t work, you need use maven debug mode (-X) to see if your maven command has parameters about cmake prefix path or OpenSSL path.
person ziyu access_time 2 years ago
No I install it directly
No I install it directly
person Raymond access_time 2 years ago
Did you use vcpkg to install openssl and other required libs?
Did you use vcpkg to install openssl and other required libs?
person ziyu access_time 2 years ago
I Builing Hadoop-3.3.1,I can't use docker in company. So i try to build with native win.
I Builing Hadoop-3.3.1,I can't use docker in company. So i try to build with native win.
person Raymond access_time 2 years ago
Which Hadoop version are you building? I recommend using Docker to build the latest Hadoop: Build Latest Hadoop on Windows 10 natively via Docker (kontext.tech)
It usually means there is no CMAKE_PREFIX_PATH set for your cmake command when building HDFS native client.
Which Hadoop version are you building? I recommend using Docker to build the latest Hadoop: Build Latest Hadoop on Windows 10 natively via Docker (kontext.tech)
It usually means there is no CMAKE_PREFIX_PATH set for your cmake command when building HDFS native client.
person ziyu access_time 2 years ago
I use Reproduce the issue
it could build with openssl
but when i build in hadoop,I can't find openssl.
I use Reproduce the issue
it could build with openssl
but when i build in hadoop,I can't find openssl.
You are welcome, Hitendra. I'm glad it is working!
In the past, there were also quite a few users that could not built correctly because they didn't follow exactly about the steps in my articles. For all the installation guides I published, I've tested them on a sandbox to ensure it works. So usually if you keep following the steps, it should work.
Cheers,
Raymond
person Hitendra access_time 4 years ago
Thanks for your reply. And big thanks to guide me through my journey.
I uninstalled all, started from scratch with instructions from your page, and the issues you have mentioned I faced exactly same. After fixing those, able to build. Now I am ready to deploy and run.
Thanks once again, and have a great day.
Thanks for your reply. And big thanks to guide me through my journey.
I uninstalled all, started from scratch with instructions from your page, and the issues you have mentioned I faced exactly same. After fixing those, able to build. Now I am ready to deploy and run.
Thanks once again, and have a great day.
person Raymond access_time 4 years ago
I am glad you have come to this step.
The error is probably because of some of the C/C++ code are not compatible with Visual C++ unfortunately (differences between VC++ and GNU C/C++). You need to manually make some adjustments.
Refer to section II Issues Fix on the build article where I shared one example of fixing some of the errors:
Compile and Build Hadoop 3.2.1 on Windows 10 Guide
Hopefully it will resolve your problem. As your build environment might not be the same as mine, for example your VC++ compiler version might be different from mine, you may encounter some other issues. If that happens, you will need to resolve them one by one. But if you've followed exact setup in my article, you should only encounter that code error I mentioned.
The command was generated by the following line in the pom.xml file:
https://github.com/apache/hadoop/blob/a3b9c37a397ad4188041dd80621bdeefc46885f2/hadoop-hdfs-project/hadoop-hdfs-native-client/pom.xml#L150
Can you try adding the following argument into your Maven build tool too?
Please change the path to the location where those C++ packages installed in your computer. Under that path, there should include sub folders like bin, lib, shared, etc.
BTW did you run
vcpkg integrate install
command?