cawka / ndnSIM-nom-rapid-car2car

Script scenarios and graph processing scripts for simulations used in "Rapid Traffic Information Dissemination Using Named Data" paper by Wang et al. (http://dx.doi.org/10.1145/2248361.2248365)
17 stars 13 forks source link

"undefined reference" errors when trying compile model with ndn-random-load-balancer strategy #8

Closed aliaksander-samuseu closed 9 years ago

aliaksander-samuseu commented 9 years ago

Hi, all.

First I'm sorry for leaving this here in addition to sending it to mailing lists, I tried to register there, but haven't got a confirmation letter, so don't know whether my letter will be put through, or not, and this is kind of urgent matter.

I've only recently installed ndnSIM and having a problem with building my first test project. I wanted to use random-load-balancer-strategy with it, and I did all as it was said on examples page of the site (here http://ndnsim.net/2.0/fw.html at a very bottom, just a single #include). It didn't work ("missing include file" kind of error), so I just found these 2 files - random-load-balancer-strategy.hpp and random-load-balancer-strategy.cpp - and tried to set a direct path to them in include directive. This time compiler found them, but I've got a lot of "undefined reference" errors anyway, here is a partial log (you can find full there: http://pastebin.com/9HE9sqba):

/usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crt1.o: In function _start': (.text+0x18): undefined reference tomain' collect2: error: ld returned 1 exit status scratch/ndnsim-multi2.cc.4.o: In function void ns3::ndn::StrategyChoiceHelper::Install<nfd::fw::RandomLoadBalancerStrategy>(ns3::Ptr<ns3::Node>, ndn::Name const&)': /opt/ndnSIM/ns-3/build/./ns3/ndnSIM/helper/ndn-strategy-choice-helper.hpp:98: undefined reference tonfd::fw::RandomLoadBalancerStrategy::STRATEGY_NAME' /opt/ndnSIM/ns-3/build/./ns3/ndnSIM/helper/ndn-strategy-choice-helper.hpp:102: undefined reference to nfd::fw::RandomLoadBalancerStrategy::STRATEGY_NAME' scratch/ndnsim-multi2.cc.4.o: In function_ZN9__gnu_cxx13new_allocatorIN3nfd2fw26RandomLoadBalancerStrategyEE9constructIS3_ISt17reference_wrapperINS1_9ForwarderEEEEEvPTDpOT0': /usr/include/c++/4.8/ext/new_allocator.h:120: undefined reference to nfd::fw::RandomLoadBalancerStrategy::STRATEGY_NAME' /usr/include/c++/4.8/ext/new_allocator.h:120: undefined reference tonfd::fw::RandomLoadBalancerStrategy::RandomLoadBalancerStrategy(nfd::Forwarder&, ndn::Name const&)' collect2: error: ld returned 1 exit status

To build my model I put my .cc file into the ns-3/scratch directory, and before I'd added this random balance strategy my model worked fine. So I also tried to move these two files in the scratch directory, to, with the exactly same result.

Could somebody offer some assistance here?

aliaksander-samuseu commented 9 years ago

Thats how my include directive looked afer I'd setup a direct path:

include "src/ndnSIM/examples/ndn-load-balancer/random-load-balancer-strategy.hpp"

I saw that the original example - src/ndnSIM/examples/ndn-load-balancer.cpp - simply included this one file with a relative path to it from its directory, so I tried to copycat this behavior, but failed.

aliaksander-samuseu commented 9 years ago

The one major difference I could spot is that original example ("ndn-load-balancer.cpp") has this directive:

"using namespace ns3;"

but source code I've been basing my model on (which I got from the site) has following directives in it:

namespace ns3 { int main(int argc, char* argv[]) { / SOME CODE ndn::StrategyChoiceHelper::Install<nfd::fw::RandomLoadBalancerStrategy>(routerNodes, "/"); // the spot undefined reference is happens at SOME OTHER CODE / } // namespace ns3

int main(int argc, char* argv[]) { return ns3::main(argc, argv); }

Can it be somehow related to the problem, and what will be the easiest way to fix it?

aliaksander-samuseu commented 9 years ago

I've commented this one string I provided above, and it compiled successfully, so this IS the root of it all. I've also tried to set an absolute namespace path to this object, like ::nfd::fw::RandomLoadBalancerStrategy>(routerNodes, "/") but still nothing

aliaksander-samuseu commented 9 years ago

I'm sorry, I was stupid. First, I misstyped in file's extension (.ccp instead of.cpp). Correcting that didn't helped by itself, but after that I just tried to include not only .hpp file, but that second .cpp file too, in this finally resolved the issue for me.