Using Protobuf installed at a custom location in Linux with CMake? - linux

I am packaging all my dependencies with Conan IO for a C++ project using CMake. I downloaded the sources of Protobuf and built them. I then added them on Conan.
On a build server, I am trying to build my CMake project, but it cannot seem to find my Protobuf library properly. Here's the log I am getting:
/home/user/Documents/project/test/build/venv/.conan/data/Protobuf/3.6.1/org/dev/package/80043e232e8ab07f4b25e67652a9490d9ad33d91/bin/protoc: error while loading shared libraries: libprotoc.so.17: cannot open shared object file: No such file or directory
CMake Warning at /home/username/Documents/project/test/build/venv/lib/python3.6/site-packages/cmake/data/share/cmake-3.10/Modules/FindProtobuf.cmake:455 (message):
Protobuf compiler version doesn't match library version 3.6.1
Call Stack (most recent call first):
/home/username/Documents/project/test/script/cmake/Env.cmake:139 (include)
CMakeLists.txt:6 (include)
-- Found Protobuf: /home/username/Documents/project/test/build/venv/.conan/data/Protobuf/3.6.1/org/dev/package/80043e232e8ab07f4b25e67652a9490d9ad33d91/lib/libprotobuf.so;-lpthread (found version "3.6.1")
/home/username/Documents/project/test/build/venv/.conan/data/Protobuf/3.6.1/org/dev/package/80043e232e8ab07f4b25e67652a9490d9ad33d91/bin/protoc: error while loading shared libraries: libprotoc.so.17: cannot open shared object file: No such file or directory
CMake Warning at /home/username/Documents/project/test/build/venv/lib/python3.6/site-packages/cmake/data/share/cmake-3.10/Modules/FindProtobuf.cmake:455 (message):
Protobuf compiler version doesn't match library version 3.6.1
Call Stack (most recent call first):
/home/username/Documents/project/test/src/shared/bysp/CMakeLists.txt:9 (find_package)
-- Found Protobuf: /home/username/Documents/project/test/build/venv/.conan/data/Protobuf/3.6.1/org/dev/package/80043e232e8ab07f4b25e67652a9490d9ad33d91/lib/libprotobuf.so;-lpthread;-lpthread (found version "3.6.1")
I'm having a hard time understanding what the problem is. It says it cannot find libprotoc.so.17, but that file exists under /lib in my conan package. It then says that it did find my library. I don't understand why it's giving me a warning and then says that it found the library. Also, protobuf is not installed on the build server. All dependencies are pre-built binaries downloaded via Conan. I am using FindProtobuf to find protobuf. Should I use something else?

Related

Set Wno-dev in particular CMakeLists

I have a project when I use cmake. I also use cmake to create a deb and an rpm package.
When building RPM we have many warnings like this:
CMake Warning (dev) at /usr/share/cmake-3.13/Modules/Internal/CPack/CPackRPM.cmake:135 (message):
CPackRPM:Warning: Path /etc/apache2/sites-available/mux.conf is not on one
of the relocatable paths! Package will be partially relocatable.
Call Stack (most recent call first):
/usr/share/cmake-3.13/Modules/Internal/CPack/CPackRPM.cmake:1001 (cpack_rpm_prepare_relocation_paths)
/usr/share/cmake-3.13/Modules/Internal/CPack/CPackRPM.cmake:1870 (cpack_rpm_generate_package)
This warning is for project developers. Use -Wno-dev to suppress it.
We have many sub CmakeLists files and even when we use "-Wno-dev" at the top of the project we still have this warning.
How can I force the Wno-dev in the CMakeLists that cause this warning?
Cmake-gui: Options|Warning Messages: Suppress Warnings - check "Developer Warnings"
From man cmake: cmake -Wno-dev ...

set(SFML_STATIC_LIBRARIES TRUE) doesn't work in cmake with SFML 2.5.1 on Debian 10 Buster

I installed SFML with the command "apt install libsfml-dev".
I can link it in cmake discribed like in this post "https://en.sfml-dev.org/forums/index.php?topic=24070.0" and everything works pretty fine.
But if I add set(SFML_STATIC_LIBRARIES TRUE) to my cmake file to link sfml static I get the following error:
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/SFML/SFMLConfig.cmake:139 (message):
Requested SFML configuration (Static) was not found
Call Stack (most recent call first):
CMakeLists.txt:30 (find_package)
CMake Error at CMakeLists.txt:30 (find_package):
Found package configuration file:
/usr/lib/x86_64-linux-gnu/cmake/SFML/SFMLConfig.cmake
but it set SFML_FOUND to FALSE so package "SFML" is considered to be NOT
FOUND.
I recognized that the SFMLConfig.cmake file wants to access a SFMLStaticTargets.cmake file in line 110, if I set(SFML_STATIC_LIBRARIES TRUE).
But my /usr/lib/x86_64-linux-gnu/cmake/SFML folder just contains the following files for Shared linking:
SFMLConfig.cmake
SFMLConfigDependencies.cmake
SFMLConfigVersion.cmake
SFMLSharedTargets.cmake
SFMLSharedTargets-none.cmake
In sfml version I can download here "https://www.sfml-dev.org/download/sfml/2.5.1/" I can also just find these files in the lib/cmake/SFML folder, but a SFMLSharedTargets-release.cmake file instead of SFMLSharedTargets-none.cmake.
What can I do to static link sfml 2.5.1 in cmake?
The error you got comes from SFMLConfigDependencies.cmake, more specifically the last few lines.
The sfml_bind_dependency macro searches your system for libXXX.so, where XXX is one of the SEARCH_NAMES.
I think it suffices to install the -dev packages of the missing dependencies as follows:
apt install libjpeg-dev libfreetype6-dev libxcb-image0-dev
I got the answer in the sfml Forum!
You have to recompile SFML, because pre-built packages for Linux don't
contain static libraries.
https://en.sfml-dev.org/forums/index.php?topic=26837

cmake doesn't find Qt5

Last night I tried to download the disassembler called "Evan's debugger (edb)", that has similar GUI to Ollydbg (Linux only).
I tried to build them via terminal using:
sudo cmake ../edb_folder
With ../edb_folder being the directory containing edb's source code.
It gives me the following error about Qt5:
-- Boost version: 1.58.0
-- Checking for module 'libgvc>=2.38.0'
--
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Qt5/Qt5Config.cmake:26 (find_package):
Could not find a package configuration file provided by "Qt5Svg" with any
of the following names:
Qt5SvgConfig.cmake
qt5svg-config.cmake
Add the installation prefix of "Qt5Svg" to CMAKE_PREFIX_PATH or set
"Qt5Svg_DIR" to a directory containing one of the above files. If "Qt5Svg"
provides a separate development package or SDK, be sure it has been
installed.
Call Stack (most recent call first):
src/CMakeLists.txt:26 (find_package)
-- Configuring incomplete, errors occurred!
See also "/home/kanna/Desktop/build/CMakeFiles/CMakeOutput.log".
But I already have Qt5 installed on my system (see this picture). Why can't cmake find Qt5?
(FYI: I'm using ubuntu 64bits)
go to synaptic and install libqt5svg5 + libqt5svg5-dev + libqt5svg5-private-dev

Boost CMake cannot find python library

After sifting through the many other questions about CMake being unable to find boost libraries I still can't figure my issue out:
My Portion of the CMakeLists related to this:
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost COMPONENTS python REQUIRED)
include_directories("${PROJECT_BINARY_DIR}")
include_directories("${PROJECT_SOURCE_DIR}/src/mazeGen")
include_directories("${PROJECT_SOURCE_DIR}/src/mazeSolve")
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(${EXECUTABLE_NAME} ${Boost_LIBRARIES})
add_executable(${EXECUTABLE_NAME} ${SOURCES} ${HEADERS})
when I specify BOOST_ROOT and try to build the project the error output is:
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:1111 (message):
Unable to find the requested Boost libraries.
Boost version: 1.55.0
Boost include path: C:/local/boost_1_55_0
Could not find the following Boost libraries:
boost_python
No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the
directory containing Boost libraries or BOOST_ROOT to the location of
Boost.
Call Stack (most recent call first):
CMakeLists.txt:36 (find_package)
Where exactly should I point CMake in order to find the libraries? And how can I do this?
all of the built libraries are located in ${BOOST_ROOT}/stage/lib and are built for VS2012, I tried setting BOOST_LIBRARYDIR to ${BOOST_ROOT}/stage/lib but this did nothing

Openssl header not found -- error

I need to compile a libwebsocket library for my ARM target which requires openssl for its functioning.
I am getting following error when i build latest libwebsocket at the time of, cmake ...
But openssl is installed here
whereis openssl
openssl: /usr/bin/openssl /usr/bin/X11/openssl /usr/share/man/man1/openssl.1ssl.gz
=================================== Error ================
-- Looking for 4 include files stdlib.h, ..., float.h - found
-- Found ZLIB: /usr/lib/arm-linux-gnueabihf/libz.so (found version "1.2.7")
ZLib include dirs: /usr/include
ZLib libraries: /usr/lib/arm-linux-gnueabihf/libz.so
Compiling with SSL support
CMake Error at /usr/local/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:97 (message):
Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
system variable OPENSSL_ROOT_DIR (missing: OPENSSL_LIBRARIES
OPENSSL_INCLUDE_DIR)
Call Stack (most recent call first):
/usr/local/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:291 (_FPHSA_FAILURE_MESSAGE)
/usr/local/share/cmake-2.8/Modules/FindOpenSSL.cmake:313 (find_package_handle_standard_args)
CMakeLists.txt:436 (find_package)
-- Configuring incomplete, errors occurred!
======================================= openssl is here ========================
ignite#ignite:~/sbox2/rootfs/rfs-raspbian_2/home/pi/libwebsockets/build$ whereis openssl
openssl: /usr/bin/openssl /usr/bin/X11/openssl /usr/share/man/man1/openssl.1ssl.gz
actually i have, source tarball from here. it have configure script to make & make install
http://www.openssl.org/source/
openssl-1.0.1e.tar.gz
So with this (openssl-1.0.1e.tar.gz) will be the right package to get --> openssl-dev or openssl-devel --- so that i can resolve this error ?
So with this (openssl-1.0.1e.tar.gz) will be the right package to get --> openssl-dev or openssl-devel --- so that i can resolve this error ?
The openssl-dev packages are for development on the host machine (which is probably x86 or x64 family). You need a cross compiled library for the target (and not the host). So openssl-dev will probably not solve your problem.
Are you targeting a generic ARM processor, iOS, or Android? If the former, you will need an arm cross-toolchain with paths set appropriately. I'm not aware of a good tutorial on cross compiling the library (and I've suffered it in the past).
There are some prebuilt configurations for generic cross compiling. Open Configure and config, and look at some of the triples. (OpenSSL does not use Automake and friends).
If iOS or Android, the OpenSSL wiki has some examples of cross compiling for the platforms. See, for example, FIPS Library and Android. The setenv-android.sh script is most important because it set paths, sysroot and toolchains. Once paths and toolschains are set, the rest is easy.
If you are targeting a generic ARM, then you could use the Android setenv-android.sh as a starting point for your generic build. Once you complete the build, then point OPENSSL_ROOT_DIR into the install directory for ARM.

Resources