在 omnetpp 中构建自己的模块时出现问题

发布于 2024-10-07 06:07:51 字数 2965 浏览 5 评论 0原文

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

错误是:

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

make

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$

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

有什么想法吗?

I'm trying to write an application using the UDP module included
in the inetmanet framework in omnetpp. The problem is that the files that I have to include don't get included in the linking phase.

The errors are:

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

make

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$

I really don't know why they get included, and my module compile fine, but in the linking phase I get "undefined reference".

Any idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冰葑 2024-10-14 06:07:51

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

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

c++filt demangles C++ 符号)。

需要符号的库将获得类似的输出(U 表示未定义):

00000000007f90a0 U UDPControlInfo

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

00000000007f90a0 T UDPControlInfo

这可以是 Tt

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

-lopptkenvd -loppenvird -lopplayoutd -u _cmdenv_lib -loppcmdenvd -loppenvird  
liboppcmdenvd liboppenvird  liboppsimd libUDPControlInfo

You can run nm on on all libraries you link with to see which library undefined symbols like this:

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

(c++filt demangles C++ symbols).

Library that requires the symbol will get output something like (U for Undefined):

00000000007f90a0 U UDPControlInfo

Library that defines/has the symbol will get output something like:

00000000007f90a0 T UDPControlInfo

This can be T or t

Of course, libraries you link with are indicated by arguments with starting by -l:

-lopptkenvd -loppenvird -lopplayoutd -u _cmdenv_lib -loppcmdenvd -loppenvird  
liboppcmdenvd liboppenvird  liboppsimd libUDPControlInfo
泅渡 2024-10-14 06:07:51

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

谢谢大家

Solved. I modified the makefile in the root directory to a simpler one, leaving all the compile and linking duties to the src's makefile.

Thanks everyone

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文