./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,
那么主要。文件格式为x86-64,但其他。o文件格式为ARM aarch64
但是…我还是不知道如何解决这个问题(换电源)。(文件格式)
main的段。在Makefile中,我确定问题在第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 err message
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…包括我. ./. ./pjlib包括我. ./. ./pjlib-util包括我. ./. ./pjnath包括我. ./. ./pjmedia/include -Wall -DPJ_AUTOCONF=1 -O2 -DPJ_IS_BIG_ENDIAN=0 -DPJ_IS_LITTLE_ENDIAN=1 -I..包括我. ./. ./pjlib包括我. ./. ./pjlib-util包括我. ./. ./pjnath包括我. ./. ./pjmedia/include
-o output/pjsua2-test-aarch64-linux-gnu/main。0
./src/pjsua2-test/main.cpp
不应该是g++
。应该是aarch64-linux-gnu-g++
。
请尝试以下步骤:
- 在configure命令行中添加
CXX=aarch64-linux-gnu-g++
并再次运行 - 确认makefile将使用
$(CXX)
来编译cpp文件,而不是g++