0

我正在尝试使用 omnetpp 的 inetmanet 框架中包含的 UDP 模块编写应用程序。问题是我必须包含的文件没有包含在链接阶段。

错误是:

opp_makemake

bedo@ethereal:~/omnetpp/samples/Basic-Broadcast-Simulation$ opp_makemake --deep -f -I../inet-sommer/src/transport/contract -I../inet-sommer/src/networklayer/contract -I../inet-sommer/src/base
Creating Makefile in /home/bedo/omnetpp/samples/Basic-Broadcast-Simulation...
Makefile created, running "make depend" to add dependencies...
opp_makedep -Y --objdirtree -I../inet-sommer/src/transport/contract -I../inet-sommer/src/networklayer/contract -I../inet-sommer/src/base -I. -Igcc-debug -Igcc-debug/src -Igcc-debug/src/flooding -Isimulations -Isimulations/bitmaps -Isimulations/results -Isrc -Isrc/flooding -f Makefile -P\$O/ --   ./*.cc gcc-debug/*.cc gcc-debug/src/*.cc gcc-debug/src/flooding/*.cc simulations/*.cc simulations/bitmaps/*.cc simulations/results/*.cc src/*.cc src/flooding/*.cc

制作

bedo@ethereal:~/omnetpp/samples/Basic-Broadcast-Simulation$ make
g++ -c -g -Wall -fno-stack-protector    -DHAVE_PCAP -DXMLPARSER=libxml -DWITH_PARSIM -DWITH_NETBUILDER  -I../inet-sommer/src/transport/contract -I../inet-sommer/src/networklayer/contract -I../inet-sommer/src/base -I. -Igcc-debug -Igcc-debug/src -Igcc-debug/src/flooding -Isimulations -Isimulations/bitmaps -Isimulations/results -Isrc -Isrc/flooding -I/home/bedo/omnetpp/include -o out/gcc-debug//src/flooding/Flooding.o src/flooding/Flooding.cc
src/flooding/Flooding.cc: In member function ‘virtual void Flooding::handleLowerMsg(cMessage*)’:
src/flooding/Flooding.cc:82: warning: unused variable ‘m’
g++ -Wl,--export-dynamic  -Wl,-rpath,/home/bedo/omnetpp/lib -Wl,-rpath,. -o out/gcc-debug//Basic-Broadcast-Simulation  out/gcc-debug//src/flooding/Flooding.o  -Wl,--whole-archive  -Wl,--no-whole-archive -L"/home/bedo/omnetpp/lib/gcc" -L"/home/bedo/omnetpp/lib" -u _tkenv_lib -lopptkenvd -loppenvird -lopplayoutd -u _cmdenv_lib -loppcmdenvd -loppenvird  -loppsimd -ldl -lstdc++ 
out/gcc-debug//src/flooding/Flooding.o: In function `Flooding::setupLowerLayer()':
/home/bedo/omnetpp/samples/Basic-Broadcast-Simulation/src/flooding/Flooding.cc:50: undefined reference to `UDPControlInfo::UDPControlInfo()'
/home/bedo/omnetpp/samples/Basic-Broadcast-Simulation/src/flooding/Flooding.cc:52: undefined reference to `UDPSocket::generateSocketId()'
out/gcc-debug//src/flooding/Flooding.o: In function `Flooding::sendMessage()':
/home/bedo/omnetpp/samples/Basic-Broadcast-Simulation/src/flooding/Flooding.cc:101: undefined reference to `UDPControlInfo::UDPControlInfo()'
/home/bedo/omnetpp/samples/Basic-Broadcast-Simulation/src/flooding/Flooding.cc:103: undefined reference to `IPAddress::ALL_HOSTS_MCAST'
collect2: ld returned 1 exit status
make: *** [out/gcc-debug//Basic-Broadcast-Simulation] Error 1
bedo@ethereal:~/omnetpp/samples/Basic-Broadcast-Simulation$

我真的不知道为什么它们被包含在内,并且我的模块编译得很好,但是在链接阶段我得到“未定义的引用”。

任何的想法?

4

2 回答 2

0

您可以nm在您链接的所有库上运行,以查看哪些库未定义符号,如下所示:

nm liboppcmdenvd.(so/a) | c++filt | grep UDPControlInfo

c++filt对 C++ 符号进行解码)。

需要该符号的库将得到类似的输出(U对于未定义):

00000000007f90a0 U UDPControlInfo

定义/具有符号的库将得到类似的输出:

00000000007f90a0 T UDPControlInfo

这可以是Tt

当然,您链接的库由以 开头的参数表示-l

-lopptkenvd -loppenvird -lopplayoutd -u _cmdenv_lib -loppcmdenvd -loppenvird  
liboppcmdenvd liboppenvird  liboppsimd libUDPControlInfo
于 2010-12-12T20:46:40.563 回答
0

解决了。我将根目录中的 makefile 修改为更简单的文件,将所有编译和链接任务留给 src 的 makefile。

谢谢大家

于 2010-12-13T05:57:10.013 回答