Open user706 opened 1 year ago
By the way, if I go ahead and use ubuntu's own crosscompiler /usr/bin/arm-linux-gnueabihf-g++
, I then the thread-stuff works and I get:
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
Edit: not - I was not using the sbuild-schroot sysroot!
-- The CXX compiler identification is GNU 11.3.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/arm-linux-gnueabihf-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
CMake Error at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find Boost (missing: Boost_INCLUDE_DIR program_options)
Call Stack (most recent call first):
/usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.22/Modules/FindBoost.cmake:2360 (find_package_handle_standard_args)
CMakeLists.txt:7 (find_package)
-- Configuring incomplete, errors occurred!
Also: If I use your toolchain, but not the sbuild schroot sysroot, calling like this:
triple=armv8-rpi3-linux-gnueabihf # Select the main toolchain
variant_triple=armv8-rpi4-linux-gnueabihf # Select a specific variant
# Configure
cmake -D CMAKE_BUILD_TYPE=Debug `#-D CMAKE_SYSROOT=/var/lib/schroot/chroots/rpi-bullseye-armhf` -S . -B
# commenting out the schroot above!!!!!!!!!!!!!!
build-$variant_triple --toolchain ~/opt/x-tools/$triple/$variant_triple.toolchain.cmake
# Build
cmake --build build-$variant_triple -j13
then I get:
-- The CXX compiler identification is GNU 13.1.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /home/albert/opt/x-tools/armv8-rpi3-linux-gnueabihf/bin/armv8-rpi3-linux-gnueabihf-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
CMake Error at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find Boost (missing: Boost_INCLUDE_DIR program_options)
Call Stack (most recent call first):
/usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.22/Modules/FindBoost.cmake:2360 (find_package_handle_standard_args)
CMakeLists.txt:7 (find_package)
-- Configuring incomplete, errors occurred!
So then threads if found (yay!!), but then I have a problem with boost program options not being found.
Edit: do I somehow need to merge the sysroots?
I've kindof tried copying your toolchain's sysroot over to the sbuild schroot...
sudo rsync -av /home/albert/opt/x-tools/armv8-rpi3-linux-gnueabihf/armv8-rpi3-linux-gnueabihf/sysroot/ /var/lib/schroot/chroots/rpizero-bullseye-armhf
sudo symlinks -rc /var/lib/schroot/chroots/rpizero-bullseye-armhf
...but the result did not work. (Or maybe there was an error copying?) ??
See https://github.com/tttapa/RPi-Cross-Cpp-Development/issues/2#issuecomment-1431703892 for an explanation and a fix.
By the way, if I go ahead and use ubuntu's own crosscompiler
/usr/bin/arm-linux-gnueabihf-g++
, I then the thread-stuff works and I get:-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
This is surprising to me. Which pthread library does it select? Does it link correctly? Which toolchain file are you using in this case?
See tttapa/RPi-Cross-Cpp-Development#2 (comment) for an explanation and a fix.
Thanks!
(Regarding ubuntu's own crosscompiler: Ah sorry, I was not clear: with ubuntu's own crosscompiler, I was not using the sbuild schroot sysroot. So it found it's own pthread, but the boost depencency failed.)
(Regarding ubuntu's own crosscompiler: Ah sorry, I was not clear: with ubuntu's own crosscompiler, I was not using the sbuild schroot sysroot. So it found it's own pthread, but the boost depencency failed.)
Ah okay, then it makes sense :)
Hi,
thanks for your great toolchains and also howto-tutorials! It is very much appreciated.
I'm having some trouble crosscompiling a project that uses Boost::program_options and thread
I'm using the sbuild schroot setup (to get boost dependency) and have installed the needed packages:
Then I try to compile with:
but get this error:
As you can see, there is a problem with the threads part.
The
CMakeLists.txt
contains thisHow does one go about, getting this to work? Is some package missing from the schroot? Or something else?
As initial investigation.... what is interesting is that the following
shows
so the sysroot in your toolchain seems to have the required pthread files.
But I am using the other sysroot in the schroot (
/var/lib/schroot/chroots/rpizero-bullseye-armhf
), because I have boost dependencies.Checking the actually used sysroot (sbuild- schroot) for pthread:
shows
Seems it also has pthread. Hmmm....
Click here for code, that one can try and cross-compile
**`CMakeLists.txt`** ```cmake cmake_minimum_required(VERSION 3.16) project(go VERSION 0.1.0 LANGUAGES CXX) set(THREADS_PREFER_PTHREAD_FLAG TRUE) find_package(Threads REQUIRED) find_package(Boost REQUIRED COMPONENTS program_options) add_executable(go main.cpp) target_link_libraries(go PRIVATE Boost::program_options Threads::Threads) include(GNUInstallDirs) install(TARGETS go RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) ``` **`main.cpp`** ```cpp #include