DietPi how to cross compile customized c software package?

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
Post Reply
gaplee
Posts: 2
Joined: Wed May 12, 2021 1:37 am

DietPi how to cross compile customized c software package?

Post by gaplee »

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.
User avatar
Joulinar
Posts: 4845
Joined: Sat Nov 16, 2019 12:49 am

Re: DietPi how to cross compile customized c software package?

Post by Joulinar »

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.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
gaplee
Posts: 2
Joined: Wed May 12, 2021 1:37 am

Re: DietPi how to cross compile customized c software package?

Post by gaplee »

Joulinar wrote: Wed May 12, 2021 2:15 am 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:

Code: Select all

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

Code: Select all

#include "stdio.h"

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

cross compile shared library: (doesn't work)

Code: Select all

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

cross compile with static option: (works)

Code: Select all

arm-linux-gnueabihf-gcc -static -o test_hw util/test/test_hw.c
User avatar
Joulinar
Posts: 4845
Joined: Sat Nov 16, 2019 12:49 am

Re: DietPi how to cross compile customized c software package?

Post by Joulinar »

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

Code: Select all

root@DietPi:~# ./util/test/test_hw 
-bash: ./util/test/test_hw: No such file or directory
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
MichaIng
Site Admin
Posts: 3032
Joined: Sat Nov 18, 2017 6:21 pm

Re: DietPi how to cross compile customized c software package?

Post by MichaIng »

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

Code: Select all

apt install libc6-dev
Post Reply