编译错误:
host/opt/ext-toolchain/bin/…/lib/gcc/arm-linux-gnueabi/5.3.1/…/…/…/…/arm-linux-gnueabi/bin/ld: /tmp/ccE6aAfo.o: undefined reference to symbol ‘pthread_join@@GLIBC_2.4’
linux/common/buildroot/host/usr//arm-buildroot-linux-gnueabi/sysroot/lib/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [test] 错误 1
原因:
没有添加libpthread库文件。
解决方案:
在makefile中添加 -lpthread :
test:__LIB
$(CPP) test.cpp -g -o encoder $(Target) $(LIBS) $(LDFLAGS) -lpthread
@echo “generate encoder success!!!”
解决pthread_join未定义引用的编译错误
本文介绍了一种常见的编译错误,即在链接阶段遇到pthread_join符号未定义的问题,并详细解释了错误产生的原因及解决方案。通过在Makefile中正确添加-lpthread选项,可以有效解决该问题。
2024





