Subject: Linker Error on Fresh ns-3.43 Install: cannot find -lns3-wifi

4 views
Skip to first unread message

Naveen Vaidyanathan

unread,
7:24 AM (10 hours ago) 7:24 AM
to ns-3-users

Hello everyone,

I'm having a persistent linker error on a fresh installation of ns-allinone-3.43 and I'm hoping someone can point me in the right direction.

The Problem: When I try to build a simple program in the scratch directory, the build fails at the final linking stage with the error /usr/bin/ld: cannot find -lns3-wifi: No such file or directory. This happens for all the core ns-3 libraries. It seems the main libraries (.so files) are not being created in the build/lib directory, even though the compilation of their source files seems to succeed.

My System:

  • ns-3 Version: ns-3.43 (from the ns-allinone-3.43.tar.bz2 package)

  • Operating System: 
    navvu@RaghunathDas:~$ lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description:    Ubuntu 24.04.3 LTS
    Release:        24.04
    Codename:       noble

Troubleshooting Steps I've Already Taken: I've spent a long time trying to debug this and have already tried:

  1. A complete, clean re-installation of ns-allinone-3.43 after removing the old directory.

  2. Installing all prerequisite and optional system dependencies for Ubuntu/Debian using a comprehensive sudo apt-get install ... command (including g++, cmake, python3-dev, ninja-build, etc.).

  3. Running ./ns3 clean and then ./ns3 build multiple times.

  4. Verifying my simple program code and scratch/CMakeLists.txt are correct. The build fails even with the most basic setup.

Even on a completely fresh install with all dependencies met, the linker cannot find the core ns-3 libraries.

Here is the final error log:

  [826/1004] Linking CXX executable /home/navvu/ns-allinone-3.43/ns-3.43/build/ns3-glowworm
 FAILED: /home/navvu/ns-allinone-3.43/ns-3.43/build/ns3-glowworm
 : && /usr/bin/c++ -Os -g -DNDEBUG scratch/CMakeFiles/ns3-glowworm.dir/ns3-glowworm.cc.o -o /home/navvu/ns-allinone-3.43/ns-3.43/build/ns3-glowworm -L/home/navvu/ns-allinone-3.43/ns-3.43/build/lib -Wl,-rpath,/home/navvu/ns-allinone-3.43/ns-3.43/build/lib -lns3-wifi -lns3-internet -lns3-mobility -lns3-applications && : /usr/bin/ld: cannot find -lns3-wifi: No such file or directory 
/usr/bin/ld: cannot find -lns3-internet: No such file or directory 
/usr/bin/ld: cannot find -lns3-mobility: No such file or directory 
/usr/bin/ld: cannot find -lns3-applications: No such file or directory
 collect2: error: ld returned 1 exit status 
ninja: build stopped: subcommand failed.  

Here are my simple test files:

scratch/ns3-glowworm.cc:

C++
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/mobility-module.h"
#include "ns3/applications-module.h"
#include "ns3/wifi-module.h"

int main(int argc, char* argv[]) {
    ns3::NodeContainer nodes;
    nodes.Create(2);
    // ... rest of the simple program ...
    ns3::Simulator::Run();
    ns3::Simulator::Destroy();
    return 0;
}

scratch/CMakeLists.txt:

add_executable(ns3-glowworm
    ns3-glowworm.cc
)

target_link_libraries(ns3-glowworm
    PRIVATE
    ns3-wifi
    ns3-internet
    ns3-mobility
    ns3-applications
)

Does anyone have an idea why a fresh ns-3 installation on my system would fail to create its own libraries, leading to this linker error? Any suggestions for further diagnostics would be greatly appreciated.

Thank you for your time.

Reply all
Reply to author
Forward
0 new messages