Sidewalk: The IoT network from Amazon
08.05.2024
Elektronik | Funk | Software
Der Technik-Blog
This article is about compiling a previously created CMake C++ project from Windows on a Raspberry Pi. With CMake as a cross-platform build tool, the "Hello World" example code can be compiled unchanged on different systems. The steps include installing the required software packages, creating a project directory, and finally using CMake and GCC to compile and run a C++ program on the Raspberry Pi.
Programming Hello World in C++ with CMake on Windows
C++ Example Code IP-Address Viewer
To compile the "Hello World" code on a Raspberry Pi, some essential software packages are required, including GCC, G++, and CMake. These tools can be installed via the Raspberry Pi package manager. After executing `apt-get update`, the following command installs the three necessary packages:
apt-get install gcc g++ cmake
GCC (GNU Compiler Collection): GCC is a collection of compilers that support various programming languages such as C and C++. It enables the translation of source code into executable programs.
G++ (GNU C++ Compiler): G++ is specifically designed for compiling C++ code. This compiler is used for the "Hello World" example in C++.
CMake: CMake is a cross-platform build tool that simplifies the management of the compilation process. It helps organize project files efficiently and translate them across different systems.
After installing these packages, the Raspberry Pi is ready for compiling and running the code.
For a clear project structure, it is recommended to create a separate directory for the "Hello World" code and the associated build files. This makes it easy to organize all relevant files. After creating a new folder named "HelloWorld" in the directory (e.g., /home/pi), the files previously created on Windows (CMakeLists.txt & src/main.cpp) can be copied into this folder. To be able to compile the program, an additional "build" folder is created in the main directory.
With CMake, the code can now be compiled on the Raspberry Pi or another Linux computer. To do this, switch to the "build" folder in the console and execute the following commands:
cmake ..
make
If the compilation was successful, the program can be started with the following command:
./HelloWorld
Every day hundreds of meteorological radiosondes fall from the sky. In this article we convert a radiosonde into a GPS tracker for APRS, RTTY & CW
read moreAlternative payload decoder for the SenseCAP T1000 LoRaWAN GPS tracker. Compatible with TTN Mapper, LoWTrack and other apps.
read moreAEQ-WEB © 2015-2024 All Right Reserved