I have built & installed openssl 1.1.1 on my system:
openssl version
OpenSSL 1.1.1h-dev xx XXX xxxx
The respective libcrypto.so and libssl.so are in /usr/local/lib64, headers in /usr/local/include. I created /etc/ld.so.conf.d/usrlocal.conf and added /usr/local/lib64 there to make sure the .so are loadable.
There is an older version (1.0.2) in /usr/lib64/ and /usr/include that i need to keep for other dependencies.
I am trying to compile OQS library (https://github.com/open-quantum-safe/liboqs) that requires
find_package(OpenSSL 1.1.1 REQUIRED)
When I try to compile the library, I get
CMake Error at /usr/local/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
system variable OPENSSL_ROOT_DIR: Found unsuitable version "1.0.2k", but
required is at least "1.1.1" (found /usr/lib64/libcrypto.so)
Call Stack (most recent call first):
/usr/local/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:443 (_FPHSA_FAILURE_MESSAGE)
/usr/local/share/cmake-3.17/Modules/FindOpenSSL.cmake:450 (find_package_handle_standard_args)
CMakeLists.txt:26 (find_package)
I have tried setting OPENSSL_ROOT_DIR to almost any value imaginable without any result; the error remains.
It seems to me thatcmake only attempts to check OPENSSL_ROOT_DIR as last attempt, and that it terminates exploration for appropriate library version after finding the first suitable version...
Now the question is obvious - how to force CMAKE to find appropriate OpenSSL version?
UPDATE
(debunked in next update) As #Tsyvarev suggested in the comments, setting OPENSSL_ROOT_DIR as environment variable helped. That means no set(OPENSSL_ROOT_DIR ...) in CMakeLists.txt or -DOPENSSL_ROOT_DIR with cmake command, but export OPENSSL_ROOT_DIR=... is what helped find_package to find the correct version.
I am still running into issues with OQS, yet this time I believe they are caused by a different issue.
lib/liboqs.a(fips202x4.c.o): In function `keccak_squeezeblocks4x.constprop.1':
fips202x4.c:(.text.keccak_squeezeblocks4x.constprop.1+0x6b): undefined reference to `KeccakP1600times4_PermuteAll_24rounds'
UPDATE 2
I am actually using OQS in another CMakeLists.txt via FetchContent as:
FetchContent_Declare(liboqs
GIT_REPOSITORY https://github.com/onavratil-monetplus/liboqs
#GIT_TAG 0.2.0
)
I made my custom fork and tweaked their CMakeLists.txt to export targets so that I can link appropriate dependencies to my binary in cmake:
target_link_libraries(myexecutable PUBLIC OQS::oqs)
The strange thing is, if I let OQS find OpenSSL on its own, I will get to the same result as in the original answer - no matter if I use -D, set() or export =.
However, if on my top level CMakeLists.txt i manually call find_package(OpenSSL 1.1.1 REQUIRED), it succeeds, respective variables OPENSSL_FOUND etc are set properly and OQS compiles. Btw I use cmake version 3.17.2.
After all it was this edit (finding OPENSSL myself) that fixed the problem, this way, -DOPENSSL_ROOT_DIR=/usr/local works as well.
I installed libssl-dev (as suggested at the bottom of the failed cmake build output) and it worked first time.
I had the Problem when I needed openssl for an Android Project. In the scenario it helped to import openssl via gradle and then linking the fetched lib like described here
Related
I am compiling a 3rd party library which uses the following commands to find Eigen3:
find_package( PkgConfig )
pkg_check_modules( EIGEN3 REQUIRED eigen3 )
include_directories(${EIGEN3_INCLUDE_DIRS})
The find_package( PkgConfig ) command runs correctly because I specified the PKG_CONFIG_EXECUTABLE variable. But pkg_check_modules( EIGEN3 REQUIRED eigen3 ) returns an error:
-- Checking for module 'eigen3'
-- No package 'eigen3' found
The Eigen3's official webpage says "It is not necessary to use CMake or install anything." It took me quite a while to realize this statement is wrong. So I ran the following to compile and install Eigen3 (version 3.3.5):
cmake -DCMAKE_CONFIGURATION_TYPES=Release -DCMAKE_INSTALL_PREFIX=E:\3rd-parties\eigen-3.3.5\install_ -G"Visual Studio 14 2015 Win64" ..
The compilation and installation process were both successful because I didn't see any failure in VS2015. But, when I go back to the build folder of the 3rd party library and run cmake again, I got exactly the same error. Eigen3 official website only provides an instruction using find_package, but not pkg-config.exe, so I next searched Google and find this thread. The answer says we need to "enable pkg-config support in the eigen3 cmake". I don't know how to enable it. Is there any specific CMake variable for this purpose? Since it is a new problem, and Eigen's main page says "To get help, stackoverflow is your best resource." so I come here for help. My question is: how to enable pkg-config support in eigen3? Or to put it another way: how to pass the pkg_check_modules( EIGEN3 REQUIRED eigen3 ) cmake command? Thanks a lot.
PS: I am working on Windows 10.
According to the Eigen3 sources, an option EIGEN_BUILD_PKGCONFIG is responsible on pkg-config support.
On Windows the whole option is disabled, but you may try to set it:
cmake -DEIGEN_BUILD_PKGCONFIG=ON <... other arguments>
When use pkg-config for find Eigen3 in CMake script, make sure that installation directory of Eigen3 is listed in CMAKE_PREFIX_PATH variable. (If CMake version used by a project is less than 3.1, then you need to additionally set PKG_CONFIG_USE_CMAKE_PREFIX_PATH to ON for tell pkgconfig module to use variable CMAKE_PREFIX_PATH. See more in the documentation for pkgconfig module.)
Want to cross-compile a C application that uses Azure IoT SDK, which unfortunately requires Cmake. Cmake refuses to build my toolchain because it claims that it cannot find Openssl that I've compiled for my target architecture.
I've tried adding OPENSSL_ROOT_DIR to the folder it's in.
SET(OPENSSL_ROOT_DIR /path/to/openssl)
I continually get the error:
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 "1.0.2g")
I also tried setting system variables to these folder as the error suggests, but it seemingly ignores them and prompts the same error. I've tried adding it to the same folder as my C compiler also to no avail.
I've run out of things to try and this point and I do not understand why it doesn't work. Any suggestions?
In Linux, I didn't have any problem setting OpenSSL.
In Windows, I solved as explained below.
Try removing CMakeCache.txt file and then do again. The cache Cmake is the main problem.
For instance, I did cmake . -DOPENSSL_ROOT_DIR=C:\openssl-1.0.2 -DOPENSSL_INCLUDE_DIR=C:\openssl-1.0.2\include -DOPENSSL_CRYPTO_LIBRARY=C:\openssl-1.0.2\crypto and everything got solved. The logic is same.
For MacOs I encounter the same error while installing ton'slite client (cmake ~/lite-client)
Solved as follows: I have open the "CMakeCache.txt" file in "liteclient-build" directory, find the line
OPENSSL_INCLUDE_DIR:PATH=OPENSSL_INCLUDE_DIR-NOTFOUND
and change it to with my openssl location
OPENSSL_INCLUDE_DIR:PATH=/usr/local/opt/openssl/include
l am trying to build a java example for the td lib following the README(https://github.com/tdlib/td/tree/master/example/java)
I have got following mistackes. Please tell how can I fix it?
C:\Users\irina\td\jnibuild>cmake -DCMAKE_BUILD_TYPE=Debug -DTD_ENABLE_JNI=ON -DCMAKE_INSTALL_PREFIX:PATH=../example/java/td ..
-- Could NOT find ccache
-- Found OpenSSL: C:/OpenSSL-Win32/include optimized;C:/OpenSSL-Win32/lib/VC/ssleay32MD.lib;debug;C:/OpenSSL-Win32/lib/VC/ssleay32MDd.lib;optimized;C:/OpenSSL-Win32/lib/VC/libeay32MD.lib;debug;C:/OpenSSL-Win32/lib/VC/libeay32MDd.lib
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
CMake Warning at CMakeLists.txt:256 (message):
Not found zlib: skip TDLib, tdactor, tdnet, tddb
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
ZLIB_LIBRARY
linked by target "tdutils" in directory C:/Users/irina/td/tdutils
-- Configuring incomplete, errors occurred!
See also "C:/Users/irina/td/jnibuild/CMakeFiles/CMakeOutput.log".
See also "C:/Users/irina/td/jnibuild/CMakeFiles/CMakeError.log".
ZLIB for Windows is a part of the GnuWin32 project (I'm not sure whether it is allowed to give links on SO). As I see, the CMakeLists.txt uses find_package to lookup the ZLIB library:
if (NOT ZLIB_FOUND)
find_package(ZLIB)
endif()
if (NOT ZLIB_FOUND)
message(WARNING "Not found zlib: skip TDLib, tdactor, tdnet, tddb")
return()
endif()
How the find_package command works is well described in the official documentation:
The command has two modes by which it searches for packages: “Module” mode and
“Config” mode. Module mode is available when the command is invoked with the
above reduced signature. CMake searches for a file called Find<package>.cmake
in the CMAKE_MODULE_PATH followed 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. Many find-
modules provide limited or no support for versioning; check the module
documentation. If no module is found and the MODULE option is not given the
command proceeds to Config mode.
I've had a look into FindZLIB.cmake on my Windows machine. The module uses the following path: ZLIB_ROOT and the following registry keys:
"[HKEY_LOCAL_MACHINE\SOFTWARE\GnuWin32\Zlib;InstallPath]"
"$ENV{PROGRAMFILES}/zlib
So, as I understand, if you install GnuWin32 using the installer, the HKLM key will be written down into the registry and CMake will be able to find the path to ZLIB. If you wish to use just the zip-archive, the ZLIB_ROOT parameter must be correctly specified when you run CMake:
cmake -DZLIB_ROOT=<PATH-to-your-unpacked-zlib> -D.....
I installed cxWidgets as follows:
sudo install wxWidgets-3.0
In the cmake file of a project I am trying to build, find_package is called:
find_package(wxWidgets REQUIRED)
However, cmake complains that it can't find the package:
CMake Error at /opt/local/share/cmake-3.4/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find wxWidgets (missing: wxWidgets_LIBRARIES
wxWidgets_INCLUDE_DIRS)
My question is, given that cxWidgets is installed (I have confirmed by running port installed), why can't cmake find it?
The problem is that MacPorts has to support multiple versions of wxWidgets and I have no good idea how to automatically let CMake find the requested version.
You have two options.
The first one is to run sudo port select wxWidgets wxWidgets-3.0. Then CMake should automatically find wxWidgets 3.0.
The second option is to add an additional argument to cmake that depends on the software you are trying to compile.
Usually one of these flags should work:
-DwxWidgets_CONFIG_EXECUTABLE=/opt/local/Library/Frameworks/wxWidgets.framework/Versions/wxWidgets/3.0/bin/wx-config
-DwxWidgets_wxrc_EXECUTABLE=/opt/local/Library/Frameworks/wxWidgets.framework/Versions/wxWidgets/3.0/bin/wxrc
Linux Flavor: Debian (Crunch Bang)
Problem Occurred: When attempting to build cvblobs with the following command
cd ~/cvblob
cmake .
Error:
CMake Error at cvBlob/CMakeLists.txt:20 (find_package):
Found package configuration file:
/usr/local/share/OpenCV/OpenCVConfig.cmake
but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered to be
NOT FOUND.
-- Configuring incomplete, errors occurred!
Well I met a similar problem when I was going with some other open source face detection modules rather than cvblobs.
Actually you will find that before these lines of error-info, there are:
CMake Warning at /usr/local/opencv-2.4.13/cmake/OpenCVConfig.cmake:163 (message):
Found OpenCV Windows Pack but it has not binaries compatible with your configuration.
You should manually point CMake variable OpenCV_DIR to your build of OpenCV library.
Call Stack (most recent call first):
CMakeLists.txt:57 (find_package)
CMake Warning at CMakeLists.txt:57 (find_package):
Found package configuration file:
/usr/local/opencv-2.4.13/cmake/OpenCVConfig.cmake
but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered to be NOT FOUND.
So you may notice that it asks you to manually point out the directory of you build version of OpenCV library.
For me, my source codes are at
/usr/local/opencv-2.4.13/
but I make and install my release build of OpenCV at
/usr/local/opencv-2.4.13/release/
so I use:
cmake -D OpenCV_DIR=/usr/local/opencv-2.4.13/release/ ..
and everything works:)
When I compile a program that use OpenCV lib, vision 2.4.8, occurs the similar error, when I point manually Opencv_DIR path to opencv/build ,visio 3.1.0, error occurred like you.
Then I point Opencv_DIR path to opencv/build whose vision is same to the program used. It works.
One of the reason could be the another OpenCV package in another path, that you had installed before. In my case, I had already installed OpenCV for Python in Anaconda package, and the CMake always wanted to refer me to that package.
I simply added:
set(OpenCV_FOUND 1)
to my CMakeList.txt file, this command simply override the other package you may had installed. The final version of CMakeList file which is working for me would be this:
set( OpenCV_FOUND 1 )
find_package(OpenCV 2.4.13 REQUIRED PATHS "C:/opencv")
set(SOURCE_FILES main.cpp)
add_executable(OpenCV_Test ${SOURCE_FILES})
Note:
1- I am using the CMakeList.txt file for Clion IDE
2- I am using it under windows. Probably you may set the relevant path if you use other OS
3- You need also change the OpenCV version if you use other version