Cross compile boost failed during linking (Ubuntu compiled for raspberry pi) - c++

I am trying to cross compile a c++ project on my ubuntu to run in raspberry pi. However, for some reason I cannot get my make file to work.
I have done few things.
I have arm environment setup that I can cross compile simple code (like hello world) on my pc and run in raspberry pi.
I have compiled boost with arm's gcc and g++, with methods found here: https://github.com/Yadoms/yadoms/wiki/Cross-compile-for-raspberry-PI
Basically is
nano ~/user-config.jam
using gcc : arm : arm-linux-gnueabihf-g++ ;
./b2 --with-atomic --with-chrono --with-date_time --with-filesystem --with-regex --with-serialization --with-thread --with-system --no-samples --no-tests toolset=gcc-arm link=static cxxflags=-fPIC
Yet, it always failed during linking
The sample I used is here:
#include <wiringPi.h>
#include <boost/filesystem.hpp>
#include <iostream>
#include <string>
int main (void)
{
boost::filesystem::create_directory("testFolder");
wiringPiSetup() ;
pinMode(0, OUTPUT) ;
for(;;)
{
digitalWrite (0, HIGH) ; delay (500) ;
digitalWrite (0, LOW) ; delay (500) ;
}
std::cout<<"hello world"<<std::endl;
return 0 ;
}
I have tested the wiringPi lib, it is working fine
And the CMakeLists.txt is
cmake_minimum_required(VERSION 3.0.0)
project(ExoController)
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -pthread -lwiringPi -o3") #you can set with add_definitions("-Wall -std=c+11, etc")
set(Boost_USE_STATIC_LIBS ON)
set(Boost_INCLUDE_DIR /home/lowlimb/rpi-kernel/boost_1_71_0)
set(Boost_LIBRARY_DIR /home/lowlimb/rpi-kernel/boost_1_71_0/stage/lib)
set(CMAKE_SYSROOT /home/lowlimb/rpi-kernel/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/arm-linux-gnueabihf/sysroot)
set(CMAKE_C_COMPILER /home/lowlimb/rpi-kernel/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER /home/lowlimb/rpi-kernel/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++)
# Search for programs only in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# Search for libraries and headers only in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(Include_DIR include)
find_package(Boost 1.71.0 COMPONENTS serialization date_time filesystem REQUIRED)
if(NOT Boost_FOUND)
message(FATAL_ERROR "boost cannot be found")
endif()
#set(Eigen_INCLUDE_DIR /home/pi/Lib/eigen-eigen-323c052e1731)
#wiringPi library libwiringPi.so
set (WPI_PATH /home/lowlimb/rpi-kernel/WiringPi/wiringPi)
# Actually find the wiringPi library object
find_library(WPI_LIB wiringPi HINTS ${WPI_PATH} NO_CMAKE_FIND_ROOT_PATH)
# Alert the user if we do not find it
if(NOT WPI_LIB)
message(FATAL_ERROR “wiringPi library not found”)
endif()
include_directories(
${Boost_INCLUDE_DIR}
${WPI_PATH}
)
link_directories(${WPI_PATH} ${Boost_LIBRARY_DIR})
enable_testing()
add_executable(exo_o main.cpp)
target_link_libraries(exo_o PRIVATE ${WPI_PATH} ${Boost_LIBRARIES})
The output I got when make is:
CMake Warning at /usr/share/cmake-3.10/Modules/FindBoost.cmake:801 (message):
New Boost version may have incorrect or missing dependencies and imported
targets
Call Stack (most recent call first):
/usr/share/cmake-3.10/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES)
/usr/share/cmake-3.10/Modules/FindBoost.cmake:1558 (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt:29 (find_package)
CMake Warning at /usr/share/cmake-3.10/Modules/FindBoost.cmake:801 (message):
New Boost version may have incorrect or missing dependencies and imported
targets
Call Stack (most recent call first):
/usr/share/cmake-3.10/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES)
/usr/share/cmake-3.10/Modules/FindBoost.cmake:1558 (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt:29 (find_package)
CMake Warning at /usr/share/cmake-3.10/Modules/FindBoost.cmake:801 (message):
New Boost version may have incorrect or missing dependencies and imported
targets
Call Stack (most recent call first):
/usr/share/cmake-3.10/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES)
/usr/share/cmake-3.10/Modules/FindBoost.cmake:1558 (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt:29 (find_package)
CMake Warning at /usr/share/cmake-3.10/Modules/FindBoost.cmake:801 (message):
New Boost version may have incorrect or missing dependencies and imported
targets
Call Stack (most recent call first):
/usr/share/cmake-3.10/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES)
/usr/share/cmake-3.10/Modules/FindBoost.cmake:1558 (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt:29 (find_package)
-- Boost version: 1.71.0
-- Found the following Boost libraries:
-- serialization
-- date_time
-- filesystem
-- system
-- Configuring done
WARNING: Target "exo_o" requests linking to directory "/home/lowlimb/rpi-kernel/WiringPi/wiringPi". Targets may link only to libraries. CMake is dropping the item.
-- Generating done
-- Build files have been written to: /home/lowlimb/Documents/testCode/build
Scanning dependencies of target exo_o
[ 50%] Building CXX object CMakeFiles/exo_o.dir/main.cpp.o
[100%] Linking CXX executable exo_o
/home/lowlimb/rpi-kernel/boost_1_71_0/stage/lib/libboost_filesystem.a(operations.o): In function `boost::filesystem::detail::current_path(boost::system::error_code*)':
operations.cpp:(.text+0xbe): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned int, unsigned int, char const*, unsigned int)'
operations.cpp:(.text+0x140): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned int, unsigned int, char const*, unsigned int)'
(I exclude most of the error since they look like a similar error).
I really don't understand why the make file cannot compile boost correctly. It did find the correct version of boost I used (the original version I installed on this computer is 1.6, only the arm's one is 1.71.0), why it still cannot function properly?
Additional Info
I would like to add more info to this question, when I first make the project, something I believe is wrong showed up
-- The C compiler identification is GNU 7.4.0
-- The CXX compiler identification is GNU 7.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
However, in my CMakeLists.txt I have already assign a different cxx complier, why it still used /usr/bin/c++?

Related

emcmake doesn't locate installed packages

I'm trying to compile a simple C++ program which uses CGAL to WASM. The problem is that for some reason find_package(CGAL) fails when using emsmake cmake, though it works fine when using cmake for compiling regular executables. I'm pretty new to compiling C++ and working with Emscripten, so this is most likely a noob question.
Running emcmake (notice CGAL warning):
cgal % emcmake cmake .
configure: cmake . -DCMAKE_TOOLCHAIN_FILE=/Users/kitty/Downloads/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=/Users/kitty/Downloads/emsdk/node/14.18.2_64bit/bin/node;--experimental-wasm-threads
-- This project requires the CGAL library, and will not be compiled.
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/kitty/Projects/cgal
Running regular cmake (no warning):
cgal % cmake .
-- The C compiler identification is AppleClang 13.1.6.13160021
-- The CXX compiler identification is AppleClang 13.1.6.13160021
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning at /usr/local/lib/cmake/CGAL/CGALConfig.cmake:92 (message):
CGAL_DATA_DIR cannot be deduced, set the variable CGAL_DATA_DIR to set the
default value of CGAL::data_file_path()
Call Stack (most recent call first):
CMakeLists.txt:10 (find_package)
-- Using header-only CGAL
-- Targetting Unix Makefiles
-- Using /Library/Developer/CommandLineTools/usr/bin/c++ compiler.
-- DARWIN_VERSION=21
-- Mac Leopard detected
-- Found GMP: /usr/local/lib/libgmp.dylib
-- Found MPFR: /usr/local/lib/libmpfr.dylib
-- Found Boost: /usr/local/lib/cmake/Boost-1.78.0/BoostConfig.cmake (found suitable version "1.78.0", minimum required is "1.48")
-- Boost include dirs: /usr/local/include
-- Boost libraries:
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found Boost: /usr/local/lib/cmake/Boost-1.78.0/BoostConfig.cmake (found version "1.78.0")
CMake Warning at /usr/local/lib/cmake/CGAL/CGAL_enable_end_of_configuration_hook.cmake:99 (message):
=======================================================================
CGAL performance notice:
The variable CMAKE_BUILD_TYPE is set to "". For performance reasons, you
should set CMAKE_BUILD_TYPE to "Release".
Set CGAL_DO_NOT_WARN_ABOUT_CMAKE_BUILD_TYPE to TRUE if you want to disable
this warning.
=======================================================================
Call Stack (most recent call first):
CMakeLists.txt:9223372036854775807 (CGAL_run_at_the_end_of_configuration)
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/kitty/Projects/cgal
Running make afterwards produces a working executable.
CMakeLists.txt (for the most part generated using cgal_create_CMakeLists utility):
# Created by the script cgal_create_CMakeLists
# This is the CMake script for compiling a set of CGAL applications.
cmake_minimum_required(VERSION 3.1...3.15)
project( executable )
# CGAL and its components
find_package( CGAL QUIET COMPONENTS )
if ( NOT CGAL_FOUND )
message(STATUS "This project requires the CGAL library, and will not be compiled.")
return()
endif()
# Boost and its components
find_package( Boost REQUIRED )
if ( NOT Boost_FOUND )
message(STATUS "This project requires the Boost library, and will not be compiled.")
return()
endif()
# include for local directory
# include for local package
# Creating entries for target: executable
# ############################
add_executable( executable test.cpp )
add_to_cached_list( CGAL_EXECUTABLE_TARGETS executable )
# Link the executable to CGAL and third-party libraries
target_link_libraries(executable PRIVATE CGAL::CGAL )
# Lines below are commented for now as they are not required for minimal repro
#set(CMAKE_EXECUTABLE_SUFFIX ".wasm")
#set_target_properties(executable PROPERTIES LINK_FLAGS "-s WASM=1 -s EXPORTED_FUNCTIONS='[_main]'")
test.cpp:
#include <iostream>
int main() {
std::cout << "Hello World!";
return 0;
}
In order for emcmake cmake .. to find the CGAL you would need to build that project for wasm and install it into the emscripten sysroot. (normally emscripten/cache/sysroot). Any libraries in /usr/lib or /usr/local/lib are most likely host libraries and therefore not compatible with wasm or emscripten.

CMake not finding boost libraries from conan

So I'm trying to get my cmake to work with conan/boost. For this I have a simple conan file:
from conans import ConanFile
class Boost_Conan_Cmake_MinimalConfig(ConanFile):
name = "Boost_Conan_Cmake_MinimalConfig"
generators = "cmake"
options = {"shared": [True, False], "st": [True, False]}
default_options = {"shared": False, "st": True}
def requirements(self):
self.requires("boost/1.69.0#_/_")
self.options["boost"].shared = False
I call this via conan install . --build=missing. This runs perfectly fine and installs boost without problems. When investigating into the folder you can also find all the boost libraries etc.
Next comes my CMakeList.txt. It's pretty straight forward:
cmake_minimum_required(VERSION 3.0)
# CHANGE PROJECT NAME, SOURCES AND DEPENDANT TARGETS
project(boost-conan CXX)
include(conanbuildinfo.cmake)
conan_basic_setup()
set(TARGET_NAME ${PROJECT_NAME})
set(${TARGET_NAME}_SRC src/main.cpp)
find_package(Boost 1.69.0 REQUIRED COMPONENTS filesystem)
add_executable(test "src/main.cpp")
target_include_directories(test PUBLIC $(Boost_INCLUDE_DIRS))
target_link_libraries(test Boost::filesystem)
However, when I try to run this CMake file I get an error:
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19041.
-- The CXX compiler identification is MSVC 19.26.28805.0
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual
Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual
Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Current conanbuildinfo.cmake directory: D:/boost-conan
-- WARN: CONAN_COMPILER variable not set, please make sure yourself that your compiler and version
matches your declared settings
CMake Error at C:/Program Files/CMake/share/cmake-
3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
Could NOT find Boost (missing: filesystem) (found suitable version
"1.69.0", minimum required is "1.69.0")
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393(_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.16/Modules/FindBoost.cmake:2179 (find_package_handle_standard_args)
CMakeLists.txt:11 (find_package)
-- Configuring incomplete, errors occurred!
See also "D:/boost-conan/CMakeFiles/CMakeOutput.log".
Does anyone have an idea how to fix this? Or does anyone have an idea why this error occurs? The Error message alone doesn't really help...
Thanks in advance!

How to compile Boost-1.76.0 with Emscripten-1.38.31 (??)

I've searched high and low for this answer and I think it should be answered in a modern setting. Most things I see are from 2013 or at the latest 2015 with comments from 2019.
to start off I am using macOS 11.2 with the most recent version of xcode 12.4.
I cloned and installed from git the most recent (as of today) repositories for boost and emscripten.
for some reason on my project when trying to integrate enscripten flags into my CMakeLists.txt file I get an error running
$ cmake .. then $ make.
the CMakeLists.txt file:
cmake_minimum_required(VERSION 3.17)
project(FernQuest) #emscripten version
if (${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
message(STATUS "using emscripten")
endif ()
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
message(STATUS "using cmake")
endif ()
#options
option(JS_ONLY "Compiles to native JS (No WASM)" OFF)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/out)
include_directories(.)
include_directories(/usr/local/include) #where boost in located
message(STATUS "finding boost!")
find_package(Boost 1.74.0 REQUIRED serialization system filesystem COMPONENTS serialization system filesystem)
if(Boost_FOUND)
message(STATUS "found boost!")
endif()
include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIR})
if(NOT Boost_FOUND)
message(FATAL_ERROR "Could not find boost!")
endif()
message(STATUS "setting sources")
SET(FQ_SRCS
../src/FernQuest.cpp
../src/Item.cpp
../src/Item.h
../src/Player.cpp
../src/Player.h
../src/Game.cpp
../src/Game.h
../src/QuestLog.cpp
../src/QuestLog.h)
SET(CMAKE_C_COMPILER emcc)
SET(CMAKE_CPP_COMPILER em++)
add_executable(FernQuest ${FQ_SRCS})
if(Boost_FOUND)
if(JS_ONLY)
message(STATUS "Setting compilation target to native JavaScript")
set(CMAKE_EXECUTABLE_SUFFIX ".js")
set_target_properties(FernQuest PROPERTIES COMPILE_FLAGS "-s USE_BOOST_HEADERS=1" LINK_FLAGS "-s USE_BOOST_HEADERS=1 -s WASM=0 -s EXPORTED_FUNCTIONS='[_main]'")
else(JS_ONLY)
message(STATUS "Setting compilation target to WASM")
set(CMAKE_EXECUTABLE_SUFFIX ".wasm.js")
set_target_properties(FernQuest PROPERTIES COMPILE_FLAGS "-s USE_BOOST_HEADERS=1" LINK_FLAGS " -s USE_BOOST_HEADERS=1 -s WASM=1 -s EXPORTED_FUNCTIONS='[_main]'")
endif(JS_ONLY)
endif()
the error:
-- The C compiler identification is AppleClang 12.0.0.12000032
-- The CXX compiler identification is AppleClang 12.0.0.12000032
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- using cmake
-- finding boost!
-- Found Boost: /usr/local/lib/cmake/Boost-1.76.0/BoostConfig.cmake (found suitable version "1.76.0", minimum required is "1.74.0") found components: serialization system filesystem serialization system filesystem
-- found boost!
-- setting sources
-- Setting compilation target to WASM
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/codiecottrell/Documents/FernQuest/emscripten/build
Scanning dependencies of target FernQuest
[ 16%] Building CXX object CMakeFiles/FernQuest.dir/Users/codiecottrell/Documents/FernQuest/src/FernQuest.cpp.o
clang: error: no such file or directory: 'USE_BOOST_HEADERS=1'
make[2]: *** [CMakeFiles/FernQuest.dir/Users/codiecottrell/Documents/FernQuest/src/FernQuest.cpp.o] Error 1
make[1]: *** [CMakeFiles/FernQuest.dir/all] Error 2
make: *** [all] Error 2
so I read up and they say that to fix this you use this below as to actually run it using the -DCMAKE_TOOLCHAIN_FILE:
$ emcmake cmake .. then $ emmake make
this error occurs:
configure: cmake .. -DCMAKE_TOOLCHAIN_FILE=/Users/codiecottrell/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR="/Users/codiecottrell/emsdk/node/14.15.5_64bit/bin/node"
-- using emscripten
-- finding boost!
CMake Error at /usr/local/Cellar/cmake/3.19.4/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:218 (message):
Could NOT find Boost (missing: Boost_INCLUDE_DIR serialization system
filesystem serialization system filesystem) (Required is at least version
"1.74.0")
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.19.4/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:582 (_FPHSA_FAILURE_MESSAGE)
/usr/local/Cellar/cmake/3.19.4/share/cmake/Modules/FindBoost.cmake:2193 (find_package_handle_standard_args)
CMakeLists.txt:21 (find_package)
-- Configuring incomplete, errors occurred!
See also "/Users/codiecottrell/Documents/FernQuest/emscripten/build/CMakeFiles/CMakeOutput.log".
make: make
-- using emscripten
-- finding boost!
CMake Error at /usr/local/Cellar/cmake/3.19.4/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:218 (message):
Could NOT find Boost (missing: Boost_INCLUDE_DIR serialization system
filesystem serialization system filesystem) (Required is at least version
"1.74.0")
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.19.4/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:582 (_FPHSA_FAILURE_MESSAGE)
/usr/local/Cellar/cmake/3.19.4/share/cmake/Modules/FindBoost.cmake:2193 (find_package_handle_standard_args)
CMakeLists.txt:21 (find_package)
-- Configuring incomplete, errors occurred!
See also "/Users/codiecottrell/Documents/FernQuest/emscripten/build/CMakeFiles/CMakeOutput.log".
make: *** [cmake_check_build_system] Error 1
My Question:
it seems that enscripten cannot find boost when running it through its own means, however cmake can clearly find it. There is also support for running boost through emscripten as I've read in both documentations however there is no clear way. What is this way and where am I going wrong? I'm going to continue to troubleshoot
EDIT
just tried $ emconfigure ./b2 toolset=gcc --prefix=/usr/local/B2
and it didn't change anything
If you're building with emscripten then the libraries on your mac (where cmake is searching) won't work; you will need to compile them statically.
I recommend trying to build your project without CMake.
If you're project only uses the boost headers (not libraries), then something like this might work:
$ em++ ../src/*.cpp -o index.html -s USE_BOOST_HEADERS=1
Otherwise you'll need to compile Boost also. Once you've done that and you have a libboost.a file, you'd compile your program like this:
$ em++ ../src/*.cpp -c -s USE_BOOST_HEADERS=1
Then link it:
$ em++ *.o /path/to/libboost.a -o index.html
Of course, depending on what other libraries you use you'll need to tweak those commands. But the general idea is to compile all the dependencies into static archive (.a) files, then compile those together to get the resulting .html (or .js or .wasm) file.
Read more about compiling with emcc.

CMake cannot find requested Boost libraries

Now that I've looked through other peoples solutions for several hours and could not find quite the right answer for my problem I would like to bring my specific problem to you. :)
I am trying to build vsomeip with CMake. For that I previously built boost 1.55, however, I get the following errors in CMake:
The C compiler identification is MSVC 19.0.24215.1
The CXX compiler identification is MSVC 19.0.24215.1
Check for working C compiler: C:/Program Files (x86)/Microsoft Visua Studio 14.0/VC/bin/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Setting build type to 'RelWithDebInfo' as none was specified.
Looking for pthread.h
Looking for pthread.h - not found
Found Threads: TRUE
CMake Error at C:/Program Files/CMake/share/cmake-3.12/Modules/FindBoost.cmake:2025 (message):
Unable to find the requested Boost libraries.
Boost version: 1.55.0
Boost include path: C:/Program Files/boost/boost_1_55_0
Could not find the following static Boost libraries:
boost_system
boost_thread
boost_log
Some (but not all) of the required Boost libraries were found. You may
need to install these additional Boost libraries. Alternatively, 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:99 (find_package)
Boost was not found!
Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
Systemd was not found, watchdog disabled!
using MSVC Compiler
Predefined unicast address: 127.0.0.1
Predefined diagnosis address: 0x00
Predefined routing application: vsomeipd
Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
CMake Warning at CMakeLists.txt:335 (message):
Doxygen is not installed. Documentation can not be built.
CMake Warning at CMakeLists.txt:374 (message):
asciidoc is not installed. Readme can not be built.
GTEST_ROOT is not defined. For building the tests the variable
GTEST_ROOT has to be defined. Tests can not be built.
Configuring incomplete, errors occurred!
See also "D:/Desktop/BACHELORARBEIT/vsomeip/build/CMakeFiles /CMakeOutput.log".
See also "D:/Desktop/BACHELORARBEIT/vsomeip/build/CMakeFiles/CMakeError.log".
It cannot find the static Boost libraries. Now, I've tried playing around with the CMakeList.txt and here is the part of it that would be supposed to handle the linking:
# Boost
set(BOOST_INCLUDE_DIR C:/Program Files/Boost/boost_1_55_0)
set(BOOST_LIBRARYDIR C:/Program Files/Boost/boost_1_55_0/stage/libs)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
find_package( Boost 1.55 COMPONENTS system thread log REQUIRED )
include_directories( ${Boost_INCLUDE_DIR} )
if(Boost_FOUND)
if(Boost_LIBRARY_DIR)
MESSAGE( STATUS "Boost_LIBRARY_DIR not empty using it: ${Boost_LIBRARY_DIR}" )
else()
if(BOOST_LIBRARYDIR)
MESSAGE( STATUS "Boost_LIBRARY_DIR empty but BOOST_LIBRARYDIR is set setting Boost_LIBRARY_DIR to: ${BOOST_LIBRARYDIR}" )
set(Boost_LIBRARY_DIR ${BOOST_LIBRARYDIR})
endif()
endif()
else()
MESSAGE( STATUS "Boost was not found!")
endif()
I have also tried using a newer boost version (1.67) with same results. Any help will be dearly appreciated!
Check if your compiled libraries are in the following directory:
C:/Program Files/Boost/boost_1_55_0/stage/libs
If not, set your lib folder directory path:
set(BOOST_LIBRARYDIR path_to_lib_directory)
As #Tsyvarev suggested I used set(Boost_DEBUG ON) to trace the exact locations and files that CMake was looking for and the discovered several problems:
1.) Setting the path to "C:/Program Files/Boost/boost_1_55_0"
causes problems, because of the space in the path
2.) It searched for the libraries covering multiple formats like: boost_thread-vc141-mt-gd-x32-1_55.lib.
However, when I built boost with incorrect parameters, so my libs were built like this:
libboost_thread-vc-mt-1_55.lib, which is not of the correct format.
3.) Unfortunately adding other options when building boost, e.g.:
b2 toolset=msvc-14.1 address-model=32 --build-type=complete
caused other errors. Also building boost_1_67_0 manually worked for me at all.
My solution to the problem was to simply take one of the third-party download( https://dl.bintray.com/boostorg/release/1.67.0/binaries/). This way all the libraries were built correctly and I had no trouble linking to them.

Cannot find MySQL and Boost includes/libs from cmake in windows

I have the following CMakeLists.txt:
cmake_minimum_required(VERSION 3.7)
project(TestProject)
message(STATUS "start running cmake...")
find_package(Boost 1.61.0 COMPONENTS system filesystem REQUIRED)
set(SOURCE_FILES main.cpp)
add_executable(TestProject ${SOURCE_FILES})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
include_directories(TestProject $ENV{MYSQL_INCLUDE_DIR})
target_link_libraries(TestProject $ENV{MYSQL_LIBRARIES})
if (Boost_FOUND)
message(STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
message(STATUS "Boost_LIBRARIES: ${Boost_LIBRARIES}")
message(STATUS "Boost_VERSION: ${Boost_VERSION}")
include_directories(TestProject ${Boost_INCLUDE_DIRS})
target_link_libraries(TestProject ${Boost_LIBRARIES})
endif ()
When I run cmake, I get the foloowing output:
> "E:\JetBrains\CLion 2017.1.1\bin\cmake\bin\cmake.exe" -DCMAKE_CXX_COMPILER="F:/MinGW/bin/g++.exe" -DCMAKE_C_COMPILER="F:/MinGW/bin/gcc.exe" -G "MinGW Makefiles" ..
-- The C compiler identification is GNU 6.1.0
-- The CXX compiler identification is GNU 6.1.0
-- Check for working C compiler: F:/MinGW/bin/gcc.exe
-- Check for working C compiler: F:/MinGW/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: F:/MinGW/bin/g++.exe
-- Check for working CXX compiler: F:/MinGW/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- start running cmake...
CMake Warning at E:/JetBrains/CLion 2017.1.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:744 (message):
Imported targets not available for Boost version
Call Stack (most recent call first):
E:/JetBrains/CLion 2017.1.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:848 (_Boost_COMPONENT_DEPENDENCIES)
E:/JetBrains/CLion 2017.1.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:1435 (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt:6 (find_package)
CMake Warning at E:/JetBrains/CLion 2017.1.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:744 (message):
Imported targets not available for Boost version
Call Stack (most recent call first):
E:/JetBrains/CLion 2017.1.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:848 (_Boost_COMPONENT_DEPENDENCIES)
E:/JetBrains/CLion 2017.1.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:1435 (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt:6 (find_package)
CMake Error at E:/JetBrains/CLion 2017.1.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:1793 (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:6 (find_package)
-- Path to MySQL include directories: E:\MySQL\MySQL Connector C++ 1.1.9\include
-- Path to MySQL library directories: E:\MySQL\MySQL Connector C++ 1.1.9\lib\opt\mysqlcppconn.lib
-- Configuring incomplete, errors occurred!
See also "F:/Ubuntu_Backup/CPPs/build/CMakeFiles/CMakeOutput.log".
If I use this CMakeLists.txt in Clion, the system is able to find the Boost libraries. Following are the entries in CMakeCache.txt that I get from CLion
//The directory containing a CMake configuration file for Boost.
Boost_DIR:PATH=Boost_DIR-NOTFOUND
//Boost filesystem library (debug)
Boost_FILESYSTEM_LIBRARY_DEBUG:FILEPATH=F:/MinGW/lib/libboost_filesystem.a
//Boost filesystem library (release)
Boost_FILESYSTEM_LIBRARY_RELEASE:FILEPATH=F:/MinGW/lib/libboost_filesystem.a
//Path to a file.
Boost_INCLUDE_DIR:PATH=F:/MinGW/include
//Boost library directory DEBUG
Boost_LIBRARY_DIR_DEBUG:PATH=F:/MinGW/lib
//Boost library directory RELEASE
Boost_LIBRARY_DIR_RELEASE:PATH=F:/MinGW/lib
//Boost system library (debug)
Boost_SYSTEM_LIBRARY_DEBUG:FILEPATH=F:/MinGW/lib/libboost_system.a
//Boost system library (release)
Boost_SYSTEM_LIBRARY_RELEASE:FILEPATH=F:/MinGW/lib/libboost_system.a
But when I run cmake separately from the commandline, I get the following in CMakeCache.txt:
//The directory containing a CMake configuration file for Boost.
Boost_DIR:PATH=Boost_DIR-NOTFOUND
//Boost filesystem library (debug)
Boost_FILESYSTEM_LIBRARY_DEBUG:FILEPATH=Boost_FILESYSTEM_LIBRARY_DEBUG-NOTFOUND
//Boost filesystem library (release)
Boost_FILESYSTEM_LIBRARY_RELEASE:FILEPATH=Boost_FILESYSTEM_LIBRARY_RELEASE-NOTFOUND
//Path to a file.
Boost_INCLUDE_DIR:PATH=Boost_INCLUDE_DIR-NOTFOUND
//Boost system library (debug)
Boost_SYSTEM_LIBRARY_DEBUG:FILEPATH=Boost_SYSTEM_LIBRARY_DEBUG-NOTFOUND
//Boost system library (release)
Boost_SYSTEM_LIBRARY_RELEASE:FILEPATH=Boost_SYSTEM_LIBRARY_RELEASE-NOTFOUND
AIM: Get the MySQL and Boost include files and libraries paths correct when building C++ project using cmake
How do I set my env. correctly so that cmake is able to find all the required include file and libraries?
Maybe you have no F:/MinGW/bin in your PATH variable?
Also, which MinGW distro you use? I would recommend you this one http://www.msys2.org/. It has very handy package manager.
You just do
pacman -S mingw-w64-x86_64-boost
and CMake finds boost without any special environment configuration.