DietPi how to cross compile customized c software package?

Hi,
I am new here. Thanks DietPi team for the true lightweight OS.

I use rpi3. And download the RPI official toolchain here
https://github.com/raspberrypi/tools

With this tool I could make the software running with -static option.

Is there official toolchain for DietPi? What’s the best way get small footprint software.

Hi,

basically DietPi is not an own OS. It is a set of scripts on top of a Debian based image. In case of Raspberry Pi devices, Raspberry OS is used. Means DietPi is an extrem slim/diet Raspberry OS. Therefore using official RPi tools is already correct.

Thanks Joulinar.

I compile a typical C hello word program through shared library way, but got below error. I have the same feeling as you, in that way shared library compile is expected to run directly, right?

Shared library bin program error:

root@DietPi:~# ./util/test/test_hw 
-bash: ./util/test/test_hw: No such file or directory

C source code:

#include "stdio.h"

int main()
{
    printf("Hello world ......\n");
}

cross compile shared library: (doesn’t work)

arm-linux-gnueabihf-gcc -o test_hw util/test/test_hw.c

cross compile with static option: (works)

arm-linux-gnueabihf-gcc -static -o test_hw util/test/test_hw.c

I’m not an expert for compiling stuff but do you have any errors during compiling?

Looks like the program you are trying to create did not exist

root@DietPi:~# ./util/test/test_hw 
-bash: ./util/test/test_hw: No such file or directory

You have the development headers installed (which include stdio.h)?

apt install libc6-dev
1 Like