2014-04-20 1 views
4

나는 친절한 팔에 양식 우분투를 크로스 컴파일하려고하지만 난 이상한 오류를 받고 있어요 :재배치 (EM : 40)

[email protected]:/home/kevin/Desktop/makef# make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-l 
gcc -o main obj/main.o obj/serial.o obj/fb.o obj/menu_main.o obj/timer.o obj/cmdin.o obj/buzzer.o obj/statemachine.o obj/inout.o obj/network.o obj/text_file_input.o obj/text_file_input_oven.o -I./ -lgd -lrt 
/usr/bin/ld: obj/main.o: Relocations in generic ELF (EM: 40) 
obj/main.o: could not read symbols: File in wrong format 
collect2: ld returned 1 exit status 
make: *** [main] Error 1 

명령 행 : 만들 ARCH = 팔 CROSS_COMPILE = 팔걸이 없음 - 리눅스 - gnueabi-1

메이크 :

export ARCH:=arm 
export CROSS_COMPILE:=arm-none-linux-gnueabi 

IDIR =./ 
CC=arm-linux-gnueabi-gcc 
CFLAGS=-I$(IDIR) 

LD= //opt/FriendlyARM/toolschain/4.5.1/arm-none-linux-gnueabi/bin/ 

ODIR=obj 
LDIR =./ 

LIBS=-lgd -lrt 

_DEPS = main.h Makefile 
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS)) 

_OBJ = main.o serial.o fb.o menu_main.o timer.o cmdin.o buzzer.o statemachine.o inout.o network.o text_file_input.o text_file_input_oven.o 
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ)) 


$(ODIR)/%.o: %.c $(DEPS) 
    $(CC) -c -o [email protected] $< $(CFLAGS) 

main: $(OBJ) 
    $(CC) -o [email protected] $^ $(CFLAGS) $(LIBS) 

.PHONY: clean 

clean: 
    rm -f $(ODIR)/*.o *~ core $(INCDIR)/*~ 

새로운 오류 메이크 파일을 업데이트 한 후 (업데이트) :

[email protected]:/home/kevin/Desktop/makef# make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi -l 
gcc -o main obj/main.o obj/serial.o obj/fb.o obj/menu_main.o obj/timer.o obj/cmdin.o obj/buzzer.o obj/statemachine.o obj/inout.o obj/network.o obj/text_file_input.o obj/text_file_input_oven.o -I./ -lgd -lrt 
/usr/bin/ld: obj/main.o: Relocations in generic ELF (EM: 40) 
obj/main.o: could not read symbols: File in wrong format 
collect2: ld returned 1 exit status 
make: [main] Error 1 (ignored) 
arm-linux-gnueabi-gcc -o main obj/main.o obj/serial.o obj/fb.o obj/menu_main.o obj/timer.o obj/cmdin.o obj/buzzer.o obj/statemachine.o obj/inout.o obj/network.o obj/text_file_input.o obj/text_file_input_oven.o -I./ -lgd -lrt 
/usr/lib/gcc/arm-linux-gnueabi/4.6/../../../../arm-linux-gnueabi/bin/ld: warning: libz.so.1, needed by /usr/lib/gcc/arm-linux-gnueabi/4.6/../../../../arm-linux-gnueabi/lib/../lib/libgd.so, not found (try using -rpath or -rpath-link) 
/usr/lib/gcc/arm-linux-gnueabi/4.6/../../../../arm-linux-gnueabi/bin/ld: warning: libexpat.so.1, needed by /usr/arm-linux-gnueabi/lib/libfontconfig.so.1, not found (try using -rpath or -rpath-link) 
/usr/arm-linux-gnueabi/lib/libfontconfig.so.1: undefined reference to `XML_GetBuffer' 
/usr/arm-linux-gnueabi/lib/libfontconfig.so.1: undefined reference to `XML_GetErrorCode' 
/usr/lib/gcc/arm-linux-gnueabi/4.6/../../../../arm-linux-gnueabi/lib/../lib/libgd.so: undefined reference to `compress' 
/usr/arm-linux-gnueabi/lib/libfreetype.so.6: undefined reference to `inflate' 
/usr/arm-linux-gnueabi/lib/libfontconfig.so.1: undefined reference to `XML_SetDoctypeDeclHandler' 
/usr/arm-linux-gnueabi/lib/libfontconfig.so.1: undefined reference to `XML_ParserCreate' 
/usr/arm-linux-gnueabi/lib/libpng12.so.0: undefined reference to `crc32' 
/usr/arm-linux-gnueabi/lib/libfontconfig.so.1: undefined reference to `XML_GetCurrentLineNumber' 
/usr/lib/gcc/arm-linux-gnueabi/4.6/../../../../arm-linux-gnueabi/lib/../lib/libgd.so: undefined reference to `uncompress' 
/usr/arm-linux-gnueabi/lib/libpng12.so.0: undefined reference to `deflateReset' 
/usr/arm-linux-gnueabi/lib/libpng12.so.0: undefined reference to `deflate' 
/usr/arm-linux-gnueabi/lib/libfontconfig.so.1: undefined reference to `XML_SetCharacterDataHandler' 
/usr/arm-linux-gnueabi/lib/libfontconfig.so.1: undefined reference to `XML_ParserFree' 
/usr/arm-linux-gnueabi/lib/libfontconfig.so.1: undefined reference to `XML_SetUserData' 
/usr/arm-linux-gnueabi/lib/libpng12.so.0: undefined reference to `deflateInit2_' 
/usr/arm-linux-gnueabi/lib/libfontconfig.so.1: undefined reference to `XML_ParseBuffer' 
/usr/arm-linux-gnueabi/lib/libfreetype.so.6: undefined reference to `inflateEnd' 
/usr/arm-linux-gnueabi/lib/libpng12.so.0: undefined reference to `deflateEnd' 
/usr/arm-linux-gnueabi/lib/libpng12.so.0: undefined reference to `inflateInit_' 
/usr/arm-linux-gnueabi/lib/libfontconfig.so.1: undefined reference to `XML_ErrorString' 
/usr/arm-linux-gnueabi/lib/libfontconfig.so.1: undefined reference to `XML_SetElementHandler' 
/usr/arm-linux-gnueabi/lib/libfreetype.so.6: undefined reference to `inflateInit2_' 
/usr/arm-linux-gnueabi/lib/libfreetype.so.6: undefined reference to `inflateReset' 
collect2: ld returned 1 exit status 
make: *** [main] Error 1 
[email protected]:/home/kevin/Desktop/makef# 

메이크 파일은 주석 (감사) 이후에 작동하고 메신저 파일을 만듭니다. 경고 : 형식이 아닌 문자열 리터럴 및 형식 인수가 없음 [-Wformat-security] 중요하다.

+0

지금 게시 한 출력 (18:50 기준)이 사용자의 Makefile과 일치하지 않습니다. – duskwuff

+0

무엇을 의미합니까? –

+0

출력 결과는 컴파일러가'gcc' (또는'cc')로 두 번,'arm-linux-gnueabi-gcc'로 두 번 실행되고 있음을 나타냅니다. 이 질문은 Makefile의 버전에서는 불가능합니다. – duskwuff

답변

4

사용해보십시오 - 그것은 비 네이티브 아키텍처로 컴파일 할 수 있도록이 지속적으로 $(CC) 변수를 사용하지 않습니다.

하는 즉, 그것을 해결 main의 스 D 자에 $(CC)cc을 변경하려면 :

main: $(OBJ) 
- gcc -o [email protected] $^ $(CFLAGS) $(LIBS) 
+ $(CC) -o [email protected] $^ $(CFLAGS) $(LIBS) 
+0

메이크 파일을 업데이트 한 후 다른 오류가 발생했습니다. –

+0

'-' 및'+'는 패치 표시기로 사용되며 Makefile의 리터럴 텍스트는 아닙니다. libz 및 libexpat와 관련된 오류는 상호 호환 시스템에 올바르게 설치된 라이브러리가 없음을 나타냅니다. – duskwuff

+0

@kevinver 당신이 지금 게시 한 오류는 링커 오류입니다. 링크해야하는 다양한 라이브러리를 사용하는 것처럼 보입니다. libz, libpng 및 libxml2 등이 있습니다. (그리고 그것들을 먼저 컴파일해야 할 수도 있습니다) – nos

5

이전에 다른 툴체인 (예 : x86), 그리고 그 오브젝트 파일들은 그 빌드에서 여전히 존재합니다.

작성,이 메이크은 크로스 컴파일에 대한 고장

make clean 
+0

make clean은 'rm -f obj/* .o * ~ core/* ~'를 리턴하고 모든 .o 파일을 제거합니다. 내가 실행할 때 동일한 오류가 발생합니다. –

+0

아, 예, @duskwuff가 다른 문제를 발견했음을 알았습니다. 이것은 동일한 "오류 유형"(혼합 도구)이지만 다른 시나리오에 기인합니다. –

+0

는 @duskwuff 제안의 결과를 부름으로 업데이트했습니다. –

0

나는 비슷한 문제를 갖고 도움이되지 않았다 깨끗했다. 빌드 폴더를 삭제하고 다시 빌드하는 작업이 끝났습니다.