如何消除这个链接错误

how to get rid of this linking error?

本文关键字:链接 错误 何消      更新时间:2023-10-16

我正在尝试编译一些文件,这很好,但当我尝试按以下方式链接它们时,我收到了一个错误:

Building target: EoCu
Invoking: GCC C++ Linker
g++ -L"/home/workspace/production-Alginterface/Shared/libs" -m32 -g -rdynamic  -Wl,-rpath-link=../../production-Alginterface/Shared/libs -g -rdynamic -o "EoCu"  ./simpleini/ConvertUTF.o ./simpleini/snippets.o  ./Tinyxpath/action_store.o ./Tinyxpath/htmlutil.o ./Tinyxpath/lex_util.o ./Tinyxpath/node_set.o ./Tinyxpath/tinystr.o ./Tinyxpath/tinyxml.o ./Tinyxpath/tinyxmlerror.o ./Tinyxpath/tinyxmlparser.o ./Tinyxpath/tokenlist.o ./Tinyxpath/xml_util.o ./Tinyxpath/xpath_expression.o ./Tinyxpath/xpath_processor.o ./Tinyxpath/xpath_stack.o ./Tinyxpath/xpath_static.o ./Tinyxpath/xpath_stream.o ./Tinyxpath/xpath_syntax.o  ./AlarmsMsg.o ./AppWatchDog.o ./BaseIteration.o ./CommunicationManager.o ./ConfigValidator.o ./FilesMng.o ./GuiInputHandler.o ./GuiManager.o ./IniReader.o ./IniWriter.o ./MessageBuilder.o ./MngFile.o ./MsgBroker.o ./NetworkDisconnectTimerCallable.o ./ShareDialog.o ./SpoIteration.o ./TCPServer.o ./Timer.o ./TimerCallable.o ./TrendsRecorder.o ./TrendsUtlFunc.o ./XMLBuilder.o ./XMLParser.o ./actmgr.o ./cdlCom.o ./entry.o ./ioctrl.o ./iteration.o ./msgqueue.o ./prmdb.o ./qthread.o ./usbDrive.o   -lrt -llog4cxx -lapr-1 -laprutil-1 -lexpat -lpthread

当我通过eclipse编译和运行时,我已经输入了正确的库,它运行得很好,但当我通过make文件这样做时,我会收到这个错误,尽管它是相同的make文件!,有人能帮我吗?

/usr/bin/ld: warning: libexpat.so.0, needed by /home/workspace/production-Alginterface/Shared/libs/libaprutil-1.so, not found (try using -rpath or -rpath-link)

提前谢谢。

eclipse很可能使用了不同的工作目录,因此rpath-link有不同的含义:

-Wl,-rpath-link=../../production-Alginterface/Shared/libs
                ^^^^^^

请尝试使用绝对路径。


如果您已经在gcc的命令行中指定了-L,为什么需要这样做?在ld(1)中,我猜会为您的其他共享库所需的共享库搜索一条单独的路径。

在这种情况下,您需要libaprutil-1.so,因为您与-laprutil-1链接。是libaprutil想要libexpat.so.0,而rpath-linkld搜索到的路径。