NS3 builds every run

241 views
Skip to first unread message

zeyad omar

unread,
Mar 10, 2024, 7:56:31 AM3/10/24
to ns-3-users
Hello,

SPOILER ALERT: I am not an expert in C++.

Initially, I was able to successfully configure ns3 and execute the command ./ns3 build. I also managed to run some scripts in the scratch folder without any issues. However, the problem arose when I decided to create a new folder within the scratch folder to set up a specific scenario.

After creating the new folder, I configured and built ns3 again, but I found that I was unable to run the .cc files in this new folder. As an alternative, I tried using cmake ., which eventually allowed me to run the files successfully. However, I noticed that each time I ran a .cc file, ns3 would build and configure the entire project. Additionally, I observed that the simulations were running approximately 1.5 times slower than before.

I would greatly appreciate it if someone could explain what might have caused these issues. Thank you in advance for your time and assistance.


summary of what I did:-

=========================
git clone ns3 repo
./ns3 configure --enable-examples
./ns3 build
./ns3 run scratch/some_sim.cc 
worked successfully and fast
===========================
./ns3 configure --enable-examples
./ns3 build
./ns3 run scratch/folder/some_sim.cc 
didn't work
===========================
cmake.
./ns3 run scratch/folder/some_sim.cc 
worked but builds the project every run and 1.5x slower.


satya singh

unread,
Mar 10, 2024, 1:26:09 PM3/10/24
to ns-3-users
you can give flag '--no-build' so that it will just run without building
./ns3 run scratch/folder/some_sim --no-build

satya singh

unread,
Mar 10, 2024, 1:27:51 PM3/10/24
to ns-3-users
can you please tell me how you did using cmake for custom application?

zeyad omar

unread,
Mar 10, 2024, 3:15:56 PM3/10/24
to ns-3-users

Hello Satya,
thank you for your response. Everything was running perfectly until I ran the command "cmake . " from the ns-3-dev directory, since then it builds in every run so I just wanted to understand why and will try your workaround, so thank you.

As for your question, I couldn't understand it well, but based on what I understood my answer is that I only followed the following instructions:-

zeyad omar

unread,
Mar 10, 2024, 3:21:49 PM3/10/24
to ns-3-users
Also, make sure to have the prerequisites found here 

satya singh

unread,
Mar 10, 2024, 3:24:52 PM3/10/24
to ns-3-users
Thank you :)

Gabriel Ferreira

unread,
Mar 12, 2024, 9:00:22 AM3/12/24
to ns-3-users
Calling CMake (the "cmake ." command) this way causes it to configure the ns-3 project in the current directory. So now you have a huge mess to clean up. 

The way not to cause this mess is moving to a cache directory, which most projects use the "build" directory, or in the ns-3 case it is the cmake-cache directory. 

mkdir cmake-cache
cd cmake-cache
cmake ..

This is the correct way to configure, which is exactly the same of using

./ns3 configure

You can run

./ns3 configure --dry-run

to check the actual commands that would be executed.

After configuring, you can use ./ns3 build and ./ns3 run program.
Do not touch cmake if you don't know what you are doing. :)

zeyad omar

unread,
Mar 12, 2024, 9:06:05 AM3/12/24
to ns-3-users
Thank you for your response. Yes, I agree with your conclusion :)
Reply all
Reply to author
Forward
0 new messages