Example project for cross-compilation and C++ development for Raspberry Pi.
Full user guide: Ubuntu to Raspberry Pi OS Cross C++ Development
Toolchains: tttapa/docker-arm-cross-toolchain
Example project for cross-compilation and C++ development for Raspberry Pi
Home Page: https://tttapa.github.io/Pages/Raspberry-Pi/C++-Development-RPiOS/index.html
Example project for cross-compilation and C++ development for Raspberry Pi.
Full user guide: Ubuntu to Raspberry Pi OS Cross C++ Development
Toolchains: tttapa/docker-arm-cross-toolchain
Hi !
Thanks a lot for your work, it helped me a lot to finally get into cross compile world.
I need to add a library (GLog) into my project but I'm struggling to make it work.
In the CMakeLists.txt of Glog, I added :
# Cross-compilation system information
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
# The sysroot contains all the libraries we might need to link against and
# possibly headers we need for compilation
set(CMAKE_SYSROOT /var/lib/schroot/chroots/schroot-name-armhf)
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
set(CMAKE_LIBRARY_ARCHITECTURE arm-linux-gnueabihf)
set(CMAKE_STAGING_PREFIX $ENV{HOME}/RPi-dev/staging-armv6-rpi)
# Set the compilers for C, C++ and Fortran
set(RPI_GCC_TRIPLE "armv6-rpi-linux-gnueabihf")
set(CMAKE_C_COMPILER ${RPI_GCC_TRIPLE}-gcc CACHE FILEPATH "C compiler")
set(CMAKE_CXX_COMPILER ${RPI_GCC_TRIPLE}-g++ CACHE FILEPATH "C++ compiler")
set(CMAKE_Fortran_COMPILER ${RPI_GCC_TRIPLE}-gfortran CACHE FILEPATH "Fortran compiler")
# Set the architecture-specific compiler flags
set(ARCH_FLAGS "-mcpu=arm1176jzf-s")
set(CMAKE_C_FLAGS_INIT ${ARCH_FLAGS})
set(CMAKE_CXX_FLAGS_INIT ${ARCH_FLAGS})
set(CMAKE_Fortran_FLAGS_INIT ${ARCH_FLAGS})
# Don't look for programs in the sysroot (these are ARM programs, they won't run
# on the build machine)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# Only look for libraries, headers and packages in the sysroot, don't look on
# the build machine
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE armhf)
It got Build without any error, but when I add just a little 'find_package (glog REQUIRED)' in the CMakeLists.txt of my Project, I get:
CMake Error at CMakeLists.txt:11 (find_package):By not providing "Findglog.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "glog", but
CMake did not find one.
Could not find a package configuration file provided by "glog" with any of
the following names:
glogConfig.cmake
glog-config.cmake
Add the installation prefix of "glog" to CMAKE_PREFIX_PATH or set
"glog_DIR" to a directory containing one of the above files. If "glog"
provides a separate development package or SDK, be sure it has been
installed.
Any clue ?
Best regards
Hi!
I want to include within my project a ZMQ messaging library. There is a base library available (libzmq3-dev) in apt, but it requires a wrapper around it (cppzmq - https://github.com/zeromq/cppzmq). How can I build and install this library in the chroot?
I used Your guide to create a cross-compiling environment to cross-compile to my RPi 4B. My project requires threads. I've added following lines to my CMakeLists.txt file:
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
target_link_libraries(projectRobot PiPCA9685 zmq Threads::Threads)
While configuring the project, CMake spits out an error, that it can't find the Threads package
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - no
-- 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 - not found
CMake Error at /snap/clion/222/bin/cmake/linux/x64/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find Threads (missing: Threads_FOUND)
Call Stack (most recent call first):
/snap/clion/222/bin/cmake/linux/x64/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
/snap/clion/222/bin/cmake/linux/x64/share/cmake-3.24/Modules/FindThreads.cmake:230 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:16 (find_package)
-- Configuring incomplete, errors occurred!
I'm using an armv8 toolchain file that looks as follows
# https://cmake.org/cmake/help/book/mastering-cmake/chapter/Cross%20Compiling%20With%20CMake.html
# Cross-compilation system information
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
# The sysroot contains all the libraries we might need to link against and
# possibly headers we need for compilation
set(CMAKE_SYSROOT /var/lib/schroot/chroots/rpizero-bullseye-armhf)
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
set(CMAKE_LIBRARY_ARCHITECTURE arm-linux-gnueabihf)
set(CMAKE_STAGING_PREFIX $ENV{HOME}/RPi-dev/staging-armv8-rpi)
# Set the compilers for C, C++ and Fortran
set(RPI_GCC_TRIPLE "armv8-rpi3-linux-gnueabihf")
set(CMAKE_C_COMPILER ${RPI_GCC_TRIPLE}-gcc CACHE FILEPATH "C compiler")
set(CMAKE_CXX_COMPILER ${RPI_GCC_TRIPLE}-g++ CACHE FILEPATH "C++ compiler")
set(CMAKE_Fortran_COMPILER ${RPI_GCC_TRIPLE}-gfortran CACHE FILEPATH "Fortran compiler")
# Set the architecture-specific compiler flags
set(ARCH_FLAGS "-mcpu=arm1176jzf-s")
set(CMAKE_C_FLAGS_INIT ${ARCH_FLAGS})
set(CMAKE_CXX_FLAGS_INIT ${ARCH_FLAGS})
set(CMAKE_Fortran_FLAGS_INIT ${ARCH_FLAGS})
# Don't look for programs in the sysroot (these are ARM programs, they won't run
# on the build machine)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# Only look for libraries, headers and packages in the sysroot, don't look on
# the build machine
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE armhf)
Looking around in rootfs of rpizero-bullseye-armhf
I can see that pthread lib is available at /var/lib/schroot/chroots/rpizero-bullseye-armhf/lib/arm-linux-gnueabihf
rwxr-xr-x 1 root root 137364 mar 30 2022 libpthread-2.31.so
-rw-r--r-- 1 root root 2383710 mar 30 2022 libpthread.a
lrwxrwxrwx 1 root root 40 mar 30 2022 libpthread.so -> /lib/arm-linux-gnueabihf/libpthread.so.0
lrwxrwxrwx 1 root root 18 mar 30 2022 libpthread.so.0 -> libpthread-2.31.so
Reinstalling the package libpthread-stubs0-dev
with sudo sbuild-apt rpizero-bullseye-armhf apt-get reinstall libpthread-stubs0-dev
brings no effect.
Is there a way for CMake to detect the Threads library?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.