gpt4 book ai didi

c - 用于 arm 的 aarch64-linux-gnu-gcc 交叉编译器失败

转载 作者:行者123 更新时间:2023-12-04 19:06:05 26 4
gpt4 key购买 nike

./configure --host=arm-elf-linux  CC=aarch64-linux-gnu-gcc --disable-sdl --disable-ffmpeg --disable-v4l2 --disable-openh264 --disable-libwebrtc --disable-libyuv

make dep && make
文件格式错误 ” 错误:
$ file main.o 
main.o: ELF 64-bit LSB relocatable, x86-64,

$file other *.o
sip_uri.o: ELF 64-bit LSB relocatable, ARM aarch64,
所以 main.o 文件格式是 x86-64 , 但其他 .o 文件格式为 ARM aarch64
但是....我仍然不知道如何解决(更改 main.o 文件格式)
Makefile 中的 main.o 段,我确定问题在行:287
# Defines for building pjsua2-test application
161 #
162 export PJSUA2_TEST_SRCDIR = ../src/pjsua2-test
163 export PJSUA2_TEST_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \
164 main.o
165 export PJSUA2_TEST_CFLAGS += $(_CFLAGS) $(PJ_VIDEO_CFLAGS)
166 export PJSUA2_TEST_CXXFLAGS = $(_CXXFLAGS) $(PJSUA2_LIB_CFLAGS) $(PJ_VIDEO_CFLAGS)
167 export PJSUA2_TEST_LDFLAGS += $(PJ_LDXXFLAGS) $(PJ_LDXXLIBS) $(LDFLAGS)
168 ifeq ($(EXCLUDE_APP),0)
169 export PJSUA2_TEST_EXE := pjsua2-test-$(TARGET_NAME)$(HOST_EXE)
170 endif
171 export CC_OUT CC AR RANLIB HOST_MV HOST_RM HOST_RMDIR HOST_MKDIR OBJEXT LD LDOUT
----------------------
pjsua2-test: $(PJSUA2_TEST_EXE)
281 $(PJSUA2_TEST_EXE): $(PJSIP_LIB) $(PJSIP_SONAME)
282 $(PJSUA2_TEST_EXE): $(PJSIP_UA_LIB) $(PJSIP_UA_SONAME)
283 $(PJSUA2_TEST_EXE): $(PJSIP_SIMPLE_LIB) $(PJSIP_SIMPLE_SONAME)
284 $(PJSUA2_TEST_EXE): $(PJSUA_LIB_LIB) $(PJSUA_LIB_SONAME)
285 $(PJSUA2_TEST_EXE): $(PJSUA2_LIB_LIB) $(PJSUA2_LIB_SONAME)
286 $(PJSUA2_TEST_EXE):
287 **$(MAKE) -f $(RULES_MAK) APP=PJSUA2_TEST app=pjsua2-test $(subst /,$(HOST_PSEP),$(BINDIR)/$@)**
makefile 错误消息
mkdir -p output/pjsua2-test-aarch64-linux-gnu/
g++ -c -DPJ_AUTOCONF=1 -g -O2 -Wall -DPJ_AUTOCONF=1 -O2 -DPJ_IS_BIG_ENDIAN=0 -DPJ_IS_LITTLE_ENDIAN=1 -I../include -I../../pjlib/include -I../../pjlib-util/include -I../../pjnath/include -I../../pjmedia/include -Wall -DPJ_AUTOCONF=1 -O2 -DPJ_IS_BIG_ENDIAN=0 -DPJ_IS_LITTLE_ENDIAN=1 -I../include -I../../pjlib/include -I../../pjlib-util/include -I../../pjnath/include -I../../pjmedia/include \
-o output/pjsua2-test-aarch64-linux-gnu/main.o \
../src/pjsua2-test/main.cpp
../src/pjsua2-test/main.cpp: In function ‘int main(int, char**)’:
../src/pjsua2-test/main.cpp:27:9: warning: division by zero [-Wdiv-by-zero]
27 | k = 1/0;
| ~^~
../src/pjsua2-test/main.cpp:26:7: warning: variable ‘k’ set but not used [-Wunused-but-set-variable]
26 | int k =1;
| ^
if test ! -d ../bin; then mkdir -p ../bin; fi
aarch64-linux-gnu-gcc -o ../bin/pjsua2-test-aarch64-linux-gnu \
output/pjsua2-test-aarch64-linux-gnu/main.o -L/home/duma/Public/pjproject2/pjlib/lib -L/home/duma/Public/pjproject2/pjlib-util/lib -L/home/duma/Public/pjproject2/pjnath/lib -L/home/duma/Public/pjproject2/pjmedia/lib -L/home/duma/Public/pjproject2/pjsip/lib -L/home/duma/Public/pjproject2/third_party/lib -lpjsua2-aarch64-linux-gnu -lstdc++ -lpjsua-aarch64-linux-gnu -lpjsip-ua-aarch64-linux-gnu -lpjsip-simple-aarch64-linux-gnu -lpjsip-aarch64-linux-gnu -lpjmedia-codec-aarch64-linux-gnu -lpjmedia-aarch64-linux-gnu -lpjmedia-videodev-aarch64-linux-gnu -lpjmedia-audiodev-aarch64-linux-gnu -lpjmedia-aarch64-linux-gnu -lpjnath-aarch64-linux-gnu -lpjlib-util-aarch64-linux-gnu -lsrtp-aarch64-linux-gnu -lresample-aarch64-linux-gnu -lgsmcodec-aarch64-linux-gnu -lspeex-aarch64-linux-gnu -lilbccodec-aarch64-linux-gnu -lg7221codec-aarch64-linux-gnu -lpj-aarch64-linux-gnu -lm -lrt -lpthread
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: output/pjsua2-test-aarch64-linux-gnu/main.o: Relocations in generic ELF (EM: 62)
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: output/pjsua2-test-aarch64-linux-gnu/main.o: Relocations in generic ELF (EM: 62)
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: output/pjsua2-test-aarch64-linux-gnu/main.o: Relocations in generic ELF (EM: 62)
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: output/pjsua2-test-aarch64-linux-gnu/main.o: Relocations in generic ELF (EM: 62)
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: output/pjsua2-test-aarch64-linux-gnu/main.o: Relocations in generic ELF (EM: 62)
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: output/pjsua2-test-aarch64-linux-gnu/main.o: Relocations in generic ELF (EM: 62)
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: output/pjsua2-test-aarch64-linux-gnu/main.o: Relocations in generic ELF (EM: 62)
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: output/pjsua2-test-aarch64-linux-gnu/main.o: Relocations in generic ELF (EM: 62)
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: output/pjsua2-test-aarch64-linux-gnu/main.o: Relocations in generic ELF (EM: 62)
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: output/pjsua2-test-aarch64-linux-gnu/main.o: Relocations in generic ELF (EM: 62)
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: output/pjsua2-test-aarch64-linux-gnu/main.o: Relocations in generic ELF (EM: 62)
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: output/pjsua2-test-aarch64-linux-gnu/main.o: Relocations in generic ELF (EM: 62)
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: output/pjsua2-test-aarch64-linux-gnu/main.o: Relocations in generic ELF (EM: 62)
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: output/pjsua2-test-aarch64-linux-gnu/main.o: error adding symbols: file in wrong format
collect2: error: ld returned 1 exit status
make[2]: *** [/home/duma/Public/pjproject2/build/rules.mak:125: ../bin/pjsua2-test-aarch64-linux-gnu] Error 1
make[2]: Leaving directory '/home/duma/Public/pjproject2/pjsip/build'
make[1]: *** [Makefile:287: pjsua2-test-aarch64-linux-gnu] Error 2
make[1]: Leaving directory '/home/duma/Public/pjproject2/pjsip/build'
make: *** [Makefile:14: all] Error 1

最佳答案

某些要链接的库可能不是使用相同的工具链构建的。您可以咨询 objdump .
示例(在您的情况下,“文件格式”可能不是确切的结果):

$ aarch64-linux-gnu-objdump -TC libz.so

libz.so: file format elf64-littleaarch64
请确认 的“文件格式”所有图书馆应该与您的工具链匹配。
更新:
您可以在 make 时看到 main.cpp 的编译消息。
g++ -c -DPJ_AUTOCONF=1 -g -O2 -Wall -DPJ_AUTOCONF=1 -O2 -DPJ_IS_BIG_ENDIAN=0 -DPJ_IS_LITTLE_ENDIAN=1 -I../include -I../../pjlib/include -I../../pjlib-util/include -I../../pjnath/include -I../../pjmedia/include -Wall -DPJ_AUTOCONF=1 -O2 -DPJ_IS_BIG_ENDIAN=0 -DPJ_IS_LITTLE_ENDIAN=1 -I../include -I../../pjlib/include -I../../pjlib-util/include -I../../pjnath/include -I../../pjmedia/include
-o 输出/pjsua2-test-aarch64-linux-gnu/main.o
../src/pjsua2-test/main.cpp
它不应该是 g++ .应该是 aarch64-linux-gnu-g++ .
请尝试以下步骤:
  • 添加 CXX=aarch64-linux-gnu-g++在配置命令行中再次运行
  • 确认您的 makefile 将使用 $(CXX)编译 cpp 文件,而不是 g++
  • 关于c - 用于 arm 的 aarch64-linux-gnu-gcc 交叉编译器失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69335337/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com