Could not find OpenSSL ... missing: OPENSSL_CRYPTO_LIBRARY - amazon-s3

I am trying to cross-compile the aws-sdk-cpp and I am getting the following error just the very first time I run CMAKE. If I run it a second time it compiles and links and I have tested the application and I can indeed use the aws-sdk-cpp functionality. I have searched and searched for days and tried all kinds of things:
Setting environment variable for OPENSSL_ROOT_DIR
Setting it in a cmake variable, etc.
I print the OPENSSL_ROOT_DIR variable right before the call to
find_package(OpenSSL REQUIRED)
and it prints the right PATH.
I have also set the variable OPENSSL_USE_STATIC_LIBS to TRUE without any difference.
I honestly don't understand what is going on since if I run it a second time it builds and links just fine.
CMake Error at /snap/cmake/1035/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (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) (found version "1.1.1n")
Call Stack (most recent call first):
/snap/cmake/1035/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
/snap/cmake/1035/share/cmake-3.22/Modules/FindOpenSSL.cmake:574 (find_package_handle_standard_args)
Projects/libraries/aws/s3/crt/aws-crt-cpp/crt/aws-c-cal/CMakeLists.txt:89 (find_package)

Ok so I have figured what was going on.
the issue was that I was setting the values for
OPENSSL_INCLUDE_DIR
OPENSSL_CRYPTO_LIBRARY
OPENSSL_SSL_LIBRARY
Once I deleted them it worked.

Related

How to solve the CMake warning for Volk and UHD package?

I am trying to create a custom block in GNU Radio which also needs to use UHD. As mentioned at this link, I added the following line to gr-module/CMakeLists.txt:
find_package(UHD "3.10.0")
But when I call the cmake../ command, I get the following two warnings:
1.The first one is for Volk.
CMake Warning (dev) at /usr/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
The package name passed to `find_package_handle_standard_args` (VOLK) does
not match the name of the calling package (Volk). This can lead to
problems in calling code that expects `find_package` result variables
(e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
/home/sohaib/prefix-3.8/lib/cmake/volk/VolkConfig.cmake:32 (find_package_handle_standard_args)
/usr/share/cmake-3.21/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
/home/sohaib/prefix-3.8/lib/cmake/gnuradio/GnuradioConfig.cmake:46 (find_dependency)
CMakeLists.txt:89 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
2.The second one is for UHD.
CMake Warning (dev) at /usr/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
The package name passed to `find_package_handle_standard_args` (PkgConfig)
does not match the name of the calling package (UHD). This can lead to
problems in calling code that expects `find_package` result variables
(e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
/usr/share/cmake-3.21/Modules/FindPkgConfig.cmake:70 (find_package_handle_standard_args)
/home/sohaib/prefix-3.8/lib/cmake/uhd/UHDConfig.cmake:42 (include)
/home/sohaib/prefix-3.8/lib/cmake/gnuradio/FindUHD.cmake:43 (find_package)
CMakeLists.txt:90 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
I built a custom block in GNU Radio a few weeks ago, and was not getting any warnings at that time. If I remove the find_package(UHD "3.10.0") line from CMakeLists.txt, I only get the warning for Volk.
How can this warning be solved?
You can't them (you could look for Volk instead of VOLK, but it might break things in other places) - you also don't have to, it's just warnings, so no action is needed.

Why does find_package(MPI) generate a warning message?

I'm using CMake 3.22.0-rc2. When I run:
find_package(MPI)
I get the warning:
CMake Warning (dev) at /opt/versions/cmake/3.22.0-rc2/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
The package name passed to `find_package_handle_standard_args` (PkgConfig)
does not match the name of the calling package (MPI). This can lead to
problems in calling code that expects `find_package` result variables
(e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
/opt/versions/cmake/3.22.0-rc2/share/cmake-3.22/Modules/FindPkgConfig.cmake:88 (find_package_handle_standard_args)
/opt/versions/cmake/3.22.0-rc2/share/cmake-3.22/Modules/FindMPI.cmake:270 (include)
examples/multi-gpu-programming-models/CMakeLists.txt:2 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
I realize I can suppress this error, but - does it have anything to do with what I've got in my CMakeLists.txt or is this some sort of internal CMake (semi-)bug?
This warning has recently been fixed in https://github.com/Kitware/CMake/commit/56d949f05f37c65401825a30be0d39bd152cc33c.
It was incorrect inclusion of module FindPkgConfig.cmake via
include(${CMAKE_CURRENT_LIST_DIR}/FindPkgConfig.cmake)
With such inclusion the call to find_package_handle_standard_args performed inside FindPkgConfig.cmake is interpreted as from the FindMPI.cmake module, because the latest find_package call has MPI argument instead of PkgConfig.
All modules like FindXXX.cmake should be included via find_package:
find_package(PkgConfig)

OPENSSL_ROOT_DIR for cmake

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

Custom path for my libraries for find_library

I am trying to compile openimageio(oiio) on Linux but it's a mess since I know almost nothing about cmake. I don't want and I can't install them on my computer directly in the /usr/local/ directory and that's the problem. I successfully compiled dependencies by executing these bash commands in each library directory :
export workingdir=<path_to_my_project>
./configure --prefix=$workingdir/sdks/deploy
make install
And this works fine, my headers are in a include directory and my libraries are in a lib directory.
Here is the structure of my project :
../<path_to_my_project>
/sdks
/build
/oiio
/png # Successfully compiled
/jpeg # Successfully compiled
/zlib # Successfully compiled
/boost # Successfully compiled
/ilmbase # Successfully compiled
/openexr # Successfully compiled
/deploy
/lib # all .a, .la and .so of successfully compiled libraries
/include # all headers of successfully compiled libraries
The problem is that there is no ./configure available in the oiio library directory so I don't know how to set the prefix path, when I execute the make command, I have errors like this :
CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
Could NOT find PNG (missing: PNG_LIBRARY) (found version "1.6.21")
Call Stack (most recent call first):
/usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:315 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake/Modules/FindPNG.cmake:105 (find_package_handle_standard_args)
src/libOpenImageIO/CMakeLists.txt:120 (find_package)
So I set variables and it makes no errors but this is not clean and I'm not sure that my libraries are correctly referenced (If I mes up the variable content, it is still working...).
set (PNG_PNG_INCLUDE_DIR "<workingdir>/sdks/deploy/include/libpng16")
set (PNG_LIBRARY_DIR "<workingdir>/sdks/deploy/lib")
Then I tried to create my own FindXXX.cmake files but some don't have a Root variable for the library so anyway I'm not sure if it correctly found the needed files, moreover, it makes errors :
CMake Error at src/cmake/modules/FindPNG.cmake:104 (include):
include could not find load file:
<workingdir>/sdks/build/oiio/src/cmake/modules/FindPackageHandleStandardArgs.cmake
Call Stack (most recent call first):
src/libOpenImageIO/CMakeLists.txt:120 (find_package)
But it finds the cmake file it anyway since other errors are correctly referenced to my file and if I print something in the cmake file it shows up when I run the make command.
Up to know, the command I am running in the oiio directory is make but I would like something that tells to the find_library function to looks other where. I could recall the function with other parameters but I can't use my own FindXXX.cmake files.
In the oiio repository, in the INSTALL file, paragraph line 43, it says to set environment variable for custom libraries, like PNGDIR, but should it point to the deploys directory or the build directory ? And they say to see CMake configuration output, maybe to know what environment variables to set, but I don't know what file they are talking.
I tried so set PNGDIR but it doesn't work, how to know if the variable name should be PNGDIR ? It can also be PNGROOT ?
export PNGDIR=<workingdir>/sdks/deploy # doesn't work
export PNGDIR=<workingdir>/sdks/build/png # doesn't work
It would be nice if someone could help me, I need this library to be compiled to use it, hope someone understood me.
Use CMAKE_PREFIX_PATH to indicate paths where find_library, find_path et al. should have a look (documentation)
Stuff like PNGDIR should no longer be used and is considered legacy that is kept for backwards compatibility. Patches for FindXXX provided by CMake to add XXX_DIR or XXX_ROOT are rejected by the CMake developers.

CMake find_package() Eclipse, OS X

I managed to create Make Target in Eclipse and add a CMakeListst.txt to a very simple project and it worked.
Now, my next step is to use two external libraries, Boost and Eigen.
My project is in /Users/MyUser/Documents/workspace/Test
The libraries are /Users/MyUser/Documents/MyLib/Libraries
Now, in the CMakeLists.txt file I try to find Boost and Eigen, which are in the libraries folder, but always the returned message is
CMake Error at CMake/TPLs/FindBoost.cmake:1126 (message): Unable to
find the requested Boost libraries.
Unable to find the Boost header files. Please set BOOST_ROOT to the
root directory containing Boost or BOOST_INCLUDEDIR to the directory
containing Boost's headers. Call Stack (most recent call first):
CMakeLists.txt:23 (FIND_PACKAGE)
-- Configuring incomplete, errors occurred! CMake Error at /Applications/CMake
2.8-11.app/Contents/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108
(message): Could NOT find Eigen3 (missing: EIGEN3_INCLUDE_DIRS
EIGEN3_VERSION_OK) (Required is at least version "2.91.0") Call
Stack (most recent call first): /Applications/CMake
2.8-11.app/Contents/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:315
(_FPHSA_FAILURE_MESSAGE) CMake/TPLs/FindEigen3.cmake:76
(find_package_handle_standard_args) CMakeLists.txt:30 (FIND_PACKAGE)
I am new to CMake, so I must be missing some way to tell CMake to search in my library folder. How can I find the packages with CMake when building the project?
BTW I'm working under Mac OS X Mavericks.
EDIT
Reading through the file FindEigen3.cmake there should be a variable called EIGEN3_INCLUDE_DIRS that points to the include directory of Eigen, is this true?
Now, from the following message
Could NOT find Eigen3 (missing: EIGEN3_INCLUDE_DIRS EIGEN3_VERSION_OK)
I would think that cmake is actually finding that directory as it says EIGEN3_VERSION_OK but then why can't cmake find the rest of the include files?
Am I still missing something? I created the environment variable within Eclipse and then add a line to the FindEigen3.cmake to test the value of the environment variable EIGEN3_INCLUDE_DIRS
message(STATUS "Eigen version: ${EIGEN3_INCLUDE_DIRS}")
But the message I'm getting is
--Eigen version: EIGEN3_INCLUDE_DIRS-NOTFOUND
Any advise?
EDIT
I tried with the question-related answers but none was able to make Eclipse+CMake find Boost and Eigen libraries. I guess the problem here is how to make Eclipse recognize the system variables.
When you do not believe in setting environment variables in Eclipse, you can pass Cmake-defines either directly to cmake command:
cmake -E chdir Release/ cmake -G "Unix Makefiles" ... -DBOOST_ROOT:PATHNAME=boost/install/dir ...
or define them in your CMakeLists.txt before find boost/eigen3
SET(BOOST_ROOT boost/install/dir)
...
FIND_PACKAGE(BOOST ... )
or use environment variables within your OS/shell. You must define them before launching the Eclipse. E.g. from bash, do
export BOOST_ROOT=boost/install/dir
eclipse
Note that you have to define all variables needed for both boost and eigen3. You can place some debugging messages in your CMakeLists.txt to confirm that you pass them correctly:
MESSAGE("Boost root: ${BOOST_ROOT}")