0

I'm pretty new with C++ development, and I wanted to use an IDE. I downloaded codelite, and everything was working fine.

The issue Recently I started development an App for the NetworkSimulator3 or Ns3, that runs with Waf(https://waf.io/). Using the codelite just for my app, and doing the build&Run on the terminal with waf seems wrong.

In the end, codelite is not recognizing a butch of files of ns3, and keep pointing errors.

What I tried to do

  1. I tried adding all Ns3 files in a single workspace, together with my app files, in hopes that everything would work. Instead I still got a bunch of "No such file or directory" errors, although these files exist and are added on the IDE

On the import, Ns3 demands us to call it like this: #import <ns3/packet.h> Although the .h is inside another folder: src/network/model/packet.h

There are a few wscripts files that probably work on these bindings, although I'm not 100% sure.

So I also tried:

  1. Adding the .h in the same folder of my app
  2. Creating a new virtual folder called ns3, and adding the headers there
  3. Including the folder with the headers in the compiler's include paths
  4. Including the folder with the headers in the linker like it was a library

Nothing worked so far

I just wanted to open the Ns3 on an IDE so I could work without several errors showing. Maybe even with some autocomplete?

Could you guys help me figure this out?

Edit I also added a "Custom build", so I can execute and build my project using waf, but the IDE errors didn't disappear

EduardoMaia
  • 591
  • 1
  • 4
  • 17

1 Answers1

1

On the import, Ns3 demands us to call it like this: #import <ns3/packet.h> Although the .h is inside another folder: src/network/model/packet.h

Headers imported with <ns3/header.h> are copied from src/module/(model/helper) to build/ns3 when you build ns-3. You need to add build/ as an include folder (e.g. -I/path/to/ns-3-dev/build), which will make <ns3/header.h> work correctly.

Not sure on the other issues, since I've never tried CodeLite.

I just wanted to open the Ns3 on an IDE so I could work without several errors showing. Maybe even with some autocomplete?

If I may recommend, try the CMake buildsystem. Clone the code and create a cmake cache folder (e.g. mkdir cmake_cache), then generate the CodeLite project (e.g. cd cmake_cache && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -G "CodeLite - Ninja" .., or -G "CodeLite - Unix Makefiles") and then open the project in cmake_cache with CodeLite. :)

Update: just read on their blog that exporting compile commands is required for code completion when using cmake. https://codeliteide.blogspot.com/2014/02/codelite-ide-60-cmake-and-clang-code.html

Gabriel
  • 106
  • 4
  • Thanks for the reply. I'll try your suggestion soon, and get back to you. – EduardoMaia May 26 '21 at 12:59
  • `./waf` automatically generates `compile_commands.json` when building, and places it in `./build/`. – Sagar May 28 '21 at 14:42
  • Hi @Sagar. I saw that file. It states several commands to build each file. What am I supposed to do with that information? – EduardoMaia May 29 '21 at 02:08
  • @EduardoMaia I don't use CodeLite, but some IDEs (eg. CLion) require compile_commands.json to use various coding features like code completion, static analysis, etc. CLion only supports CMake (might have changed since I last checked). – Sagar May 29 '21 at 03:08