dgibson / dtc

Device Tree Compiler
219 stars 130 forks source link

cannot static cross compile #32

Closed lyq1996 closed 4 years ago

lyq1996 commented 4 years ago

Hi, Im using arm-linux-gnueabi-gcc to compile dtc, inorder to use it on TWRP recovery, but when I run

~/dtc# make NO_PYTHON=1 CC=arm-linux-gnueabi-gcc CFLAGS=-static -s

it always say

dtc.o: In function `main':
dtc.c:(.text+0xd00): undefined reference to `dt_to_yaml'
collect2: error: ld returned 1 exit status
Makefile:338: recipe for target 'dtc' failed
make: *** [dtc] Error 1

Could you please tell me what to do , thank you!!!

lyq1996 commented 4 years ago

The problem seems to resolve.

Here is my step:

~/dtc# make NO_PYTHON=1 CC=arm-linux-gnueabi-gcc

and then

~/dtc# make NO_PYTHON=1 CC=arm-linux-gnueabi-gcc CFLAGS=-static -s

then rm dtc and run again

~/dtc# make NO_PYTHON=1 CC=arm-linux-gnueabi-gcc CFLAGS=-static -s
~/dtc# file dtc
ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, for GNU/Linux 3.2.0, BuildID[sha1]=e14f20a57ad58c674d2e5113299a7c2cf5ad9b3a, stripped

Just don't know why..
Sorry for bothering. Thank you.

dgibson commented 4 years ago

Hm, I'm not really sure why that would be happening.

Do you have libyaml installed? This might happen if the NO_YAML variable was somehow being set differently for building the .o files and the final link, but I don't know why that would happen.