#5, First Floor, 4th Street , Dr. Subbarayan Nagar, Kodambakkam, Chennai-600 024 pro@slogix.in

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • pro@slogix.in
  • +91- 81240 01111

Social List

How to compile c++ code in ns2?

Description

To compile a C++ file, the network simulator calls g++ compiler with the filename containing the C++ code. In following example, main.cc file can be executed by the g++ command. The output of main.cc creates an object file called main.o.

Sample Code

FileName: main.cc
#include <iostream>
using namespace std;
int main (void)
{ int a = 10;
cout << "The value of a is: " << a << endl;
return 0;
}
Command:
g++ main.cc -o main