如何摆脱这种链接错误?

时间:2015-03-31 13:58:45

标签: c++ c compiler-errors linker linker-errors

我正在尝试编译一些文件,它很好但是当我尝试将它们链接起来时,我得到一个错误:

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)

提前感谢。

1 个答案:

答案 0 :(得分:2)

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

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

尝试使用绝对路径。


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

在这种情况下,您需要libaprutil-1.so,因为您与-laprutil-1相关联。 libaprutil需要libexpat.so.0rpath-linkld搜索的路径。

相关问题