Do I need precompil or any?

53 views
Skip to first unread message

non

unread,
Nov 29, 2018, 1:48:04 AM11/29/18
to ns-3-users
Hi everyone.

I try to build mesh-net work on ns3.26.
But it isn't work.
I think it is bad to code.

Do I need precompil for header and code?

Would you help me?

Thank you.

------Hierarchy------
ns 3.26 --- scratch--- exp06-simpleMesh.cc
                              ---simpleMeshLib.h
                             ---simpleMeshLib.cc


------error------

Undefined symbols for architecture x86_64:

  "_main", referenced from:

     implicit entry/start for main executable

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)


Undefined symbols for architecture x86_64:

  "MeshDot11sSim::RunSim(int, char**)", referenced from:

      _main in exp06-simpleMesh.cc.14.o

  "MeshDot11sSim::MeshDot11sSim()", referenced from:

      _main in exp06-simpleMesh.cc.14.o

  "vtable for MeshDot11sSim", referenced from:

      MeshDot11sSim::~MeshDot11sSim() in exp06-simpleMesh.cc.14.o

  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)



-----code(exp06-simpleMesh.cc)-----
12 int main (int argc, char *argv[])
13 {
14 MeshDot11sSim sim;
15 ns3::PacketMetadata::Enable ();
16
17 sim.RunSim(argc, argv);
18
19 return 0;
20 }

-----code(simpleMeshLib.h)-----

class MeshDot11sSim
{
    public:
// Init test
MeshDot11sSim ();

    //private:
uint32_t m_xSize; //x size of the grid
uint32_t m_ySize; //y size of the grid
double   m_step;  //separation between nodes
double   m_randomStart;
double   m_totalTime;
uint16_t m_packetSize;
uint32_t m_nIfaces;
bool     m_chan;
std::string m_txrate;
std::string m_root;
bool     m_showRtable;

//to calculate the lenght of the simulation
float m_timeTotal, m_timeStart, m_timeEnd;

// List of network nodes
NodeContainer meshNodes;
NodeContainer staNodes;
Ptr<Node>     *n;
Ptr<Node>     bgr;

// List of all mesh point devices
NetDeviceContainer meshDevices;
NetDeviceContainer p2pDevices;

// MeshHelper. Report is not static methods
MeshHelper mesh;

    //private:
// Run test
virtual void RunSim (int argc, char **argv);

// Configure test from command line arguments
virtual void Configure (int argc, char ** argv);

// Create nodes and setup their mobility

-----code(simpleMeshLib.cc)-----
void 
MeshDot11sSim::RunSim (int argc, char *argv[])
{
NS_LOG_FUNCTION(this);

Configure (argc, argv);

// use ConfigStore
// following default configuration are same to
// ./waf --run "exp06-simpleMesh --ns3::ConfigStore::Mode=Save 
// --ns3::ConfigStore::Filename=config.txt"
std::string cf = std::string(PROG_DIR) + "config.txt";
Config::SetDefault ("ns3::ConfigStore::Filename", StringValue (cf));
Config::SetDefault ("ns3::ConfigStore::FileFormat", StringValue ("RawText"));
Config::SetDefault ("ns3::ConfigStore::Mode", StringValue ("Save"));
ConfigStore config;
  config.ConfigureDefaults ();

CreateTopologyNodes ();
ConfigureMeshLayer();
InstallInternetStack ();

//SetUpUdpApplication();

Rob Kers

unread,
Nov 29, 2018, 3:22:52 AM11/29/18
to ns-3-users
Hi!

Did you add you .h and .cc files to .waf config files? Otherwise the WAF build tool does not know about your files and wont link them. 

" clang: error: linker command failed with exit code 1 (use -v to see invocation)"
indicates a linking problem.

pdbarnes

unread,
Nov 29, 2018, 8:07:16 AM11/29/18
to ns-3-users
That’s true in modules in src, but not in scratch. In scratch there are two ways to arrange your code.

For single .cc files with a main() function just put them in scratch. When you want to spread your code over multiple.cc files, as in this case, you should put them all in a subdirectory of scratch. You don’t need to edit any wscript files. These two cases are explained in the tutorial.

Peter
Reply all
Reply to author
Forward
0 new messages