jcmvbkbc / esp32-linux-build

xtensa linux build scripts for the esp32s3 and esp32
http://wiki.osll.ru/doku.php/etc:users:jcmvbkbc:linux-xtensa:esp32s3
99 stars 19 forks source link

how to compile my own c program by cross compiler? #12

Closed org0000h closed 4 months ago

org0000h commented 4 months ago

This project is so cool,I compiled everything and it run well as expected. Now I want to write some c program. For example if I have a helloworld.c, how to cross compile it? I want to run it in ssh by using nfs mounted folder. I will be very happy if you can gave me some example script for cross compiling user program. Thank you very much.

org0000h commented 4 months ago

I tried this but it doesn't work: crosstool-NG/builds/xtensa-esp32s3-linux-uclibcfdpic/bin/xtensa-esp32s3-linux-uclibcfdpic-gcc mytest.c ✭master /home/asia/github/esp32-linux-build/build/crosstool-NG/builds/xtensa-esp32s3-linux-uclibcfdpic/lib/gcc/xtensa-esp32s3-linux-uclibcfdpic/14.1.0/../../../../xtensa-esp32s3-linux-uclibcfdpic/bin/ld: /home/asia/github/esp32-linux-build/build/crosstool-NG/builds/xtensa-esp32s3-linux-uclibcfdpic/lib/gcc/xtensa-esp32s3-linux-uclibcfdpic/14.1.0/../../../../xtensa-esp32s3-linux-uclibcfdpic/lib/libgcc_s.so.1: error adding symbols: file in wrong format collect2: error: ld returned 1 exit status

org0000h commented 4 months ago

source:

#include <stdio.h>
int main(){
printf("helloworld\n");
}
jcmvbkbc commented 4 months ago

The environment variable XTENSA_GNU_CONFIG must point to a dynconfig library for the toolchain to work. See how it's done in the script.

org0000h commented 4 months ago

Thanks for response so quick. It is successful to compile.Nothing outputed when cross compiling. But when I run it :

/etc/nfs # ./a.out
Segmentation fault
org0000h commented 4 months ago

It's working . I missed it up. Thank you !

/etc/nfs # ./a.out
helloworld