1. undefined reference to `__aeabi_dcmpun'
__aeabi_dcmpun这个符号的实现位于libgcc, 但是Linker文件中已包含了libgcc, 为何还提示找不到符号?
问题在于几个lib库的顺序安排,打开linker.ld文件,调整文件末尾的库文件列表顺序,如下:
/DISCARD/ : { libgcc.a ( * ) libc.a ( * ) libnosys.a ( * ) /*libm.a ( * )*/ /*libg.a ( * )*/ }
调整为
/DISCARD/ : { libc.a ( * ) libnosys.a ( * ) libgcc.a ( * ) /*libm.a ( * )*/ /*libg.a ( * )*/ }
即可完成编译。
2.lib库相互引用,互相依赖(交叉引用)链接解决办法
Linux GCC中,如果lib a依赖b,b又依赖a,链接的时候无论a放在前,还是b放在前,都会提示 undefined reference to `xxx'。
解决办法一:
链接的时候a链接两次,即: -la -lb -la
解决办法二:
在相互依赖的库间加上 -Wl,--start-group -Wl,--end-group,如果当前的库找不到定义,会在当前的group中从头到尾查询,以找出其定义。
$(CC) -g -o $(TARGET) $(OBJ) $(LIB_FLAG) -Wl,--start-group -lssl -lcrypto -losip2 -leXosip2 -losipparser2 -lpthread -lmd5 -Wl,--end-group