Hi,
I am trying to link an external library "itpp" to ns3 and build it. I have made modifications in an example files of ns3 by including the required header file and declaring a function. We have confirmed that itpp is installed on the system.
Highlighted are the code changes made in first.cc example file.
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/applications-module.h"
#include <itpp/itcomm.h>
using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("FirstScriptExample");
int
main (int argc, char *argv[])
{
uint32_t nPackets = 1;
itpp::RNG_randomize();
CommandLine cmd;
cmd.AddValue("nPackets", "Number of packets to echo", nPackets);
cmd.Parse (argc, argv);
Following is the command executed to build first.cc with the changes:
[infonet@infonet-E460 ~/repos_ns3/ns-3-allinone/ns-3-dev ] LINKFLAGS="-litpp" ./waf --run scratch/first
Waf: Entering directory `/home/infonet/repos_ns3/ns-3-allinone/ns-3-dev/build'
[2390/2443] Linking build/scratch/first
scratch/first.cc.3.o: In function `main':
/home/infonet/repos_ns3/ns-3-allinone/ns-3-dev/build/../scratch/first.cc:32: undefined reference to `itpp::RNG_randomize()'
collect2: error: ld returned 1 exit status
Waf: Leaving directory `/home/infonet/repos_ns3/ns-3-allinone/ns-3-dev/build'
Build failed
-> task in 'first' failed (exit status 1):
{task 139725482419280: cxxprogram first.cc.3.o -> first}
['/usr/bin/g++', '-litpp', '-pthread', '-pthread', 'scratch/first.cc.3.o', '-o', '/home/infonet/repos_ns3/ns-3-allinone/ns-3-dev/build/scratch/first', '-Wl,-Bstatic', '-Wl,-Bdynamic', '-Wl,--no-as-needed', '-Llib', '-lns3-dev-aodv-debug', '-lns3-dev-test-debug', '-lns3-dev-dsr-debug', '-lns3-dev-mesh-debug', '-lns3-dev-netanim-debug', '-lns3-dev-wave-debug', '-lns3-dev-wifi-debug', '-lns3-dev-lr-wpan-debug', '-lns3-dev-lte-debug', '-lns3-dev-spectrum-debug', '-lns3-dev-antenna-debug', '-lns3-dev-applications-debug', '-lns3-dev-csma-layout-debug', '-lns3-dev-dsdv-debug', '-lns3-dev-flow-monitor-debug', '-lns3-dev-internet-apps-debug', '-lns3-dev-wimax-debug', '-lns3-dev-point-to-point-layout-debug', '-lns3-dev-nix-vector-routing-debug', '-lns3-dev-olsr-debug', '-lns3-dev-sixlowpan-debug', '-lns3-dev-tap-bridge-debug', '-lns3-dev-internet-debug', '-lns3-dev-bridge-debug', '-lns3-dev-point-to-point-debug', '-lns3-dev-mpi-debug', '-lns3-dev-traffic-control-debug', '-lns3-dev-buildings-debug', '-lns3-dev-propagation-debug', '-lns3-dev-uan-debug', '-lns3-dev-mobility-debug', '-lns3-dev-energy-debug', '-lns3-dev-config-store-debug', '-lns3-dev-csma-debug', '-lns3-dev-fd-net-device-debug', '-lns3-dev-virtual-net-device-debug', '-lns3-dev-topology-read-debug', '-lns3-dev-network-debug', '-lns3-dev-stats-debug', '-lns3-dev-core-debug', '-lrt', '-lgtk-x11-2.0', '-lgdk-x11-2.0', '-lpangocairo-1.0', '-latk-1.0', '-lcairo', '-lgdk_pixbuf-2.0', '-lgio-2.0', '-lpangoft2-1.0', '-lpango-1.0', '-lgobject-2.0', '-lglib-2.0', '-lfontconfig', '-lfreetype', '-lxml2']
I have not made any changes in wscript file. How do we link external libraries and call functions in NS3?