Installing Cross Compiling Tools for Raspberry Pi Part 2, Configuring crosstool-NG

Ames Computer Geek Corner News Installing Cross Compiling Tools for Raspberry Pi Part 2, Configuring crosstool-NG NYC New York City North Bergen County
https://www.raspberrypi.org/

Crosstool-NG is configured with a graphical user interface that presents a menu-structured set of options. These options let you specify the way you want your toolchain built, where you want it installed, what architecture and specific processor it will support, etc. The value for those options are then stored in a configuration file.

The configurator works the same way you configure your Linux kernel. To start the customization, open menuconfig by typing ct-ng menuconfig. First allow extending the toolchain after it is created since it is read only by default. Next, change the Target options to the cpu version of your Raspberry Pi ( e.g. cortex-a72 ). Next, change the Tuple's vendor string in Toolchain options to your Raspberry Pi version ( e.g. rpi3 ). Once That is not, re=run ct-ng build to build the toolchain.


To test the toolchain, create a simple, hello world program. If we can compile and run it on target, the toolchain is working. In order to compile it using the toolchain, we need to add the bin dir to PATH by adding ~/x-tools/aarch64-rpi3-linux-gnu/bin to our path either by editing your environment variables or typing PATH=$PATH:~/x-tools/aarch64-rpi3-linux-gnu/bin in the terminal. Compile the code using by typing in the following in the terminal, aarch64-rpi3-linux-gnu-g++ hello_world.cpp -o hello_world. If you are using C, you would use aarch64-rpic-linux-gnu-gcc instead. There should be no build errors and a file named hello_world will be created. To test the program, copy the file to your Raspberry Pi and run it.

The example above is a simple case of cross compiling for the Raspberry Pi where there are no special libraries that need to be included. When there are libraries that need to be added to the compile, it gets more complicated. In our next article, we will cover some of those cases.