【记录】用交叉编译器arm-xscale-linux-gnueabi交叉编译出错:ld: warning: libexpat.so.1, needed by liblog4c.so, not found (try using -rpath or -rpath-link)

【问题】

折腾:

【记录】用交叉编译器arm-xscale-linux-gnueabi交叉编译一个基于嵌入式Linux的无线HART的项目

出错:

/home/CLi/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/lib/gcc/arm-xscale-linux-gnueabi/4.6.0/../../../../arm-xscale-linux-gnueabi/bin/ld: warning: libexpat.so.1, needed by /home/CLi/develop/crosstool-ng/x-tools/armxscalelog4c/lib/liblog4c.so, not found (try using -rpath or -rpath-link)
/home/CLi/develop/crosstool-ng/x-tools/armxscalelog4c/lib/liblog4c.so: undefined reference to `XML_SetEndElementHandler'
/home/CLi/develop/crosstool-ng/x-tools/armxscalelog4c/lib/liblog4c.so: undefined reference to `XML_ParserCreate'
/home/CLi/develop/crosstool-ng/x-tools/armxscalelog4c/lib/liblog4c.so: undefined reference to `XML_GetErrorCode'
/home/CLi/develop/crosstool-ng/x-tools/armxscalelog4c/lib/liblog4c.so: undefined reference to `XML_SetUserData'
/home/CLi/develop/crosstool-ng/x-tools/armxscalelog4c/lib/liblog4c.so: undefined reference to `XML_GetCurrentColumnNumber'
/home/CLi/develop/crosstool-ng/x-tools/armxscalelog4c/lib/liblog4c.so: undefined reference to `XML_ParseBuffer'
/home/CLi/develop/crosstool-ng/x-tools/armxscalelog4c/lib/liblog4c.so: undefined reference to `XML_GetCurrentLineNumber'
/home/CLi/develop/crosstool-ng/x-tools/armxscalelog4c/lib/liblog4c.so: undefined reference to `XML_SetCommentHandler'
/home/CLi/develop/crosstool-ng/x-tools/armxscalelog4c/lib/liblog4c.so: undefined reference to `XML_ErrorString'
/home/CLi/develop/crosstool-ng/x-tools/armxscalelog4c/lib/liblog4c.so: undefined reference to `XML_ParserFree'
/home/CLi/develop/crosstool-ng/x-tools/armxscalelog4c/lib/liblog4c.so: undefined reference to `XML_SetStartElementHandler'
/home/CLi/develop/crosstool-ng/x-tools/armxscalelog4c/lib/liblog4c.so: undefined reference to `XML_Parse'
/home/CLi/develop/crosstool-ng/x-tools/armxscalelog4c/lib/liblog4c.so: undefined reference to `XML_GetBuffer'
/home/CLi/develop/crosstool-ng/x-tools/armxscalelog4c/lib/liblog4c.so: undefined reference to `XML_GetCurrentByteIndex'
/home/CLi/develop/crosstool-ng/x-tools/armxscalelog4c/lib/liblog4c.so: undefined reference to `XML_SetCharacterDataHandler'
collect2: ld returned 1 exit status
Makefile:109: recipe for target `armWHGSMainApp' failed
make: *** [armWHGSMainApp] Error 1

即,libexpat貌似有点问题。

 

【解决过程】

1.貌似很明显,即:

没有找到对应的libexpat而已。

所以,去把之前的LDLIBS中,加上对应的expat的路径:

LIBEXPATROOTDIR = /home/CLi/develop/crosstool-ng/x-tools/armxscaleexpat
LDLIBS		= xxx -L$(LIBEXPATROOTDIR)/lib -lexpat

对应的,路径:

cgwin\home\CLi\develop\crosstool-ng\x-tools\armxscaleexpat\lib

下面,是有

libexpat.a

libexpat.so

libexpat.so.1

的。

2.再去编译试试,然后就可以了。

 

【总结】

当编译出现:

ld: warning: libexpat.so.1, needed by liblog4c.so, not found (try using -rpath or -rpath-link)

的错误时,说明:

在ld阶段,加载liblog4c时,其所依赖的expat库:libexpat没有找到。

解决办法:

给对应的ld的参数中,加上对应的

-L$(LIBEXPATROOTDIR)/lib -lexpat

其中LIBEXPATROOTDIR是你的expat库的(安装的)根目录。即可。



发表评论

电子邮件地址不会被公开。 必填项已用*标注

无觅相关文章插件,快速提升流量