libz.so is missing when trying to build - c++

I am building a project using cmake 3.5.1 and ninja on Ubuntu 16.04 server.
When I try to build I get an error about finding a zlib dependency..
ninja: error: '/usr/lib/libz.so' needed by 'MyProject', missing and no known rule to make it.
I have checked and confirmed I have zlib1g-dev package installed.
I assume the following line in cmake is what is looking for the libz.so
target_link_libraries(MyProject ${ZLIB_LIBRARIES})
The following line is present in the CMakeLists.txt
find_package(ZLIB REQUIRED)

Related

Cmake error: Target "restinio::restinio" contains relative path in its INTERFACE_INCLUDE_DIRECTORIES:

Preface: I am using Clion with Cygwin. I have installed vcpkg following their instructions. Then I followed restinio instructions to install restinio using vcpkg. Since restinio required fmt and http-parser I installed both of those too.
I have installed both the x86-windows version and x64-windows version of all 3 packages.
I linked vcpkg cmake file as per their instructions in Clion and have regenerated the CMakeCache
Currently I am trying to build specifically the x64-windows version (I was having other errors with the x86 version and I got further with the x64 version).
I have looked at this, and my initial error is different along with there is stuff inside of the directory that is in the relative path.
cmake_minimum_required(VERSION 3.23)
project(testing2)
set(CMAKE_CXX_STANDARD 14)
# RESTinio dependencies:
# 1. ASIO or Boost::ASIO (goes as headers, vcpkg knows where)
# 2. HTTP parser
find_package(unofficial-http-parser CONFIG REQUIRED)
# 3. fmtlib
find_package(fmt CONFIG REQUIRED)
# RESTinio itself
find_package(restinio CONFIG REQUIRED)
# Make your project dependent on restinio,
# and let cmake deal with all the headers paths and linked libs.
add_executable(testing2 main.cpp)
target_link_libraries(testing2 PRIVATE restinio::restinio)
cmake Options: -DCMAKE_TOOLCHAIN_FILE=C:\dev\vcpkg\vcpkg-master\scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET:STRING=x64-windows
Clion output in the cmake tab:
-- Configuring done
CMake Error in CMakeLists.txt:
Target "restinio::restinio" contains relative path in its
INTERFACE_INCLUDE_DIRECTORIES:
"C:/dev/vcpkg/vcpkg-master/installed/x64-windows/include"
CMake Error in CMakeLists.txt:
IMPORTED_LOCATION not set for imported target
"unofficial::http_parser::http_parser" configuration "Debug".
-- Generating done
CMake Error:
Running
'/cygdrive/c/Program Files/JetBrains/CLion 2021.2.3/bin/ninja/cygwin/ninja.exe' '-C' '/cygdrive/c/Users/Tally/Desktop/DevStuffs/Testing2/cmake-build-debug' '-t' 'recompact'
failed with:
ninja: error: build.ninja:35: loading 'CMakeFiles/rules.ninja': No such file or directory
include CMakeFiles/rules.ninja
^ near here
CMake Generate step failed. Build files cannot be regenerated correctly.
[Finished]
the path: "C:/dev/vcpkg/vcpkg-master/installed/x64-windows/include" exists and has asio, fmt, and restinio dirs along with asio.hpp and http_parser.h.
I have tried adding:
target_link_libraries(main PRIVATE unofficial::http_parser::http_parser) as vcpkg suggests when I install, but it gives me the same error just replaced restinio::restinio with unofficial::http_parser::http_parser.

Compile sfml with conan and cmake

I'm trying to compile sfml with cmake and conan package manager. Here is my conanfile.txt:
[requires]
sfml/2.5.0#bincrafters/stable
[options]
sfml:graphics=true
sfml:window=True
sfml:audio=True
sfml:network=True
sfml:system=True
[generators]
cmake
[imports]
And my cmake file:
cmake_minimum_required (VERSION 3.10)
project(projectx)
add_executable(
${PROJECT_NAME}
src/main.cpp
)
target_link_libraries(
${PROJECT_NAME}
${CONAN_LIBS}
)
rtype
And when i compile here is my error :
ERROR: Unable to find 'sfml/2.5.0#bincrafters/stable' in remotes
The bincrafters remote is deprecated IIRC. You should use the conancenter remote instead (this is already configured as one of your remotes in newer conan versions - check with conan remote list to be sure, it should list 'conancenter: https://center.conan.io [Verify SSL: True]').
In your conanfile.txt simply replace the bincrafters/stable part by _/_ (I'm not 100% sure but maybe you don't need that #_/_ part at all, i.e. sfml/2.5.0 could suffice, already). The conancenter remote should be used.

Generate wasm file using emscripten

I want to compile SealPIR library using emscripten to generate a wasm file.
When using this command:
emcmake cmake .
I get this error:
CMake Error at CMakeLists.txt:19 (find_package):
By not providing "FindSEAL.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "SEAL", but
CMake did not find one.
Could not find a package configuration file provided by "SEAL" (requested
version 3.2.0) with any of the following names:
SEALConfig.cmake
seal-config.cmake
Add the installation prefix of "SEAL" to CMAKE_PREFIX_PATH or set
"SEAL_DIR" to a directory containing one of the above files. If "SEAL"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
See also "/home/Zied/webassembly/SealPIR/CMakeFiles/CMakeOutput.log".
emcmake: error: 'cmake . -DCMAKE_TOOLCHAIN_FILE=/home/Zied/webassembly/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR="/home/Zied/webassembly/emsdk/node/14.15.5_64bit/bin/node"' failed (1)
SEAL is correctly installed. when i run the same command without emcmake it works just fine.
This is my CMakeList
cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
project(SealPIR VERSION 2.1 LANGUAGES CXX)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
add_executable(main
main.cpp
)
add_library(sealpir STATIC
pir.cpp
pir_client.cpp
pir_server.cpp
)
find_package(SEAL 3.2.0 EXACT REQUIRED)
target_link_libraries(main sealpir SEAL::seal)
When using a toolchain file for cross compiling, CMake will by default disable system libraries. It won't search into any directory to avoid finding files that is not compatible with the target system.
You think you didn't used a toolchain file? Think again! emcmake hides that from you. Look carefully at the error output.
Here you compiled the SEAL library, but you installed it in the default path, which is /usr/local.
We can tell CMake to explicitly search there, but I wouldn't recommend, but you can try if it works:
emcmake cmake . -CMAKE_PREFIX_PATH=/usr/local
The proper solution would be to create a directory with all the emscripten libraries in it:
# In the SEAL build directory
emcmake cmake .. -DCMAKE_INSTALL_PREFIX=/home/anblic/webassembly/install
Then after installing the libraries in that directory, you can set the prefix path in the same directory as the install path:
# Assuming you're in a build/ subdirectory
emcmake cmake .. -DCMAKE_PREFIX_PATH=/home/anblic/webassembly/install

CMake find_package failure while looking for Qt5 on Ubuntu 20.04 LTS - cmake version mismatch

I stumbled upon this problem while trying to find Qt5 with CMake.
Qt5 is installed on my Ubuntu through Ubuntu apt program, but there is an error occurring that looks like this:
[cmake] CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Qt5/Qt5Config.cmake:3 (message):
[cmake] Qt5 requires at least CMake version 3.1.0
While my cmake version is 3.16.3 from Ubuntu repositories:
cmake version 3.16.3
CMake suite maintained and supported by Kitware (kitware.com/cmake).
And when i looked into Qt5Config.cmake file, the error happens on first line:
if (CMAKE_VERSION VERSION_LESS 3.1.0)
message(FATAL_ERROR "Qt5 requires at least CMake version 3.1.0")
endif()
And i have no idea how to resolve it, other than changing VERSION_LESS to VERSION_GREATER in all .cmake files for Qt installation resolves the problem. (Which obviously, does not make any sense).
Does anyone have any thoughts on this?

CMake Error: CMAKE_MODULE_PATH does not contain FindPoppler.cmake

my working platform is Ubuntu 18.04 LTS.
I'm trying to install QCViewer from github. It seems a lot of packages are needed from my installation of QCViewer from source. So, I worked on my way through the github repository, installed all the build dependencies at/usr, , and enter the folder QCViewer/build/release and run ./build. This worked fine untill the package "poppler" where cmake gives the following error:
root#ubuntu:/home/link/QCViewer-master/build/release# ./build
CMake Error at QCViewer/CMakeLists.txt:63 (FIND_PACKAGE):
By not providing "FindPoppler.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Poppler", but
CMake did not find one.
Could not find a package configuration file provided by "Poppler" with any
of the following names:
PopplerConfig.cmake
poppler-config.cmake
Add the installation prefix of "Poppler" to CMAKE_PREFIX_PATH or set
"Poppler_DIR" to a directory containing one of the above files. If
"Poppler" provides a separate development package or SDK, be sure it has
been installed.
-- Configuring incomplete, errors occurred!
See also "/home/link/QCViewer-master/build/release/CMakeFiles/CMakeOutput.log".
make: *** No rule to make target 'install'. Stop.
and also noted that:
link#ubuntu:~$ pkg-config --libs --cflags poppler
-I/usr/include/poppler -lpoppler
Meanwhile, I find that this project's CMakeLists.txtgiven as follows:
cmake_minimum_required (VERSION 2.6)
project(QCViewer)
find_package(PkgConfig)
pkg_check_modules(GTKMM gtkmm-2.4 freetype2 poppler-glib)
add_subdirectory(QCViewer)
so how can I fix it?