Negar Javadzadeh
Negar Javadzadeh

Reputation: 397

Importing OpenCV and TensorFlow Lite into ns-3.38

I am currently working on a project that involves using OpenCV and TensorFlow Lite within the ns-3.38 simulation environment. Despite several attempts, I am facing difficulties with configuring and integrating these libraries correctly.

I have tried updating the CMakeLists.txt file to include both OpenCV and TensorFlow Lite, but I continue to encounter issues, particularly with dependencies and path configurations. Additionally, linking the required libraries to ensure compatibility with ns-3.38 has proven to be challenging.

I added this part to my CMakeLists.txt file before ns3_cmake_package():

#Add OpenCV to the project
find_package(OpenCV REQUIRED)

# Add include directories for OpenCV
include_directories(${OpenCV_INCLUDE_DIRS})

#Add OpenCV to the project
find_package(OpenCV REQUIRED)

# Add include directories for OpenCV
include_directories(${OpenCV_INCLUDE_DIRS})

# Define the executable target for your simulation
add_executable(OpenCV scratch/EDEN/EDEN.cc)
# Link your executable with OpenCV libraries
target_link_libraries(OpenCV ${OpenCV_LIBS})

#----------------------------------------------------------

# Set TensorFlow Lite directories
set(TFLITE_DIR "/home/negar/workspace/tensorflow/tensorflow/lite")
set(TFLITE_LIB "${TFLITE_DIR}/libtensorflow-lite.a")

# Include TensorFlow Lite headers
include_directories("/home/negar/workspace/tensorflow")
include_directories("/home/negar/workspace/flatbuffers/include")

# Define the executable
add_executable(TensorFlow scratch/EDEN/node.cc)

# Link the executable with TensorFlow Lite
target_link_libraries(TensorFlow ${TFLITE_LIB}) 

When I run ./ns3 build it returns:

/home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.cc: In member function ‘void NodeServer::LogMobilityData()’:
/home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.cc:196:48: error: invalid use of incomplete type ‘class ns3::Node’
  196 |         Ptr<MobilityModel> mobility = GetNode()->GetObject<MobilityModel>();
      |                                                ^~
In file included from /home/negar/workspace/ns-allinone-3.38/ns-3.38/build/include/ns3/application.h:1,
                 from /home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.h:4,
                 from /home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.cc:1:
/home/negar/workspace/ns-allinone-3.38/ns-3.38/src/network/model/application.h:32:7: note: forward declaration of ‘class ns3::Node’
   32 | class Node;
      |       ^~~~
/home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.cc:196:73: error: expected primary-expression before ‘>’ token
  196 |         Ptr<MobilityModel> mobility = GetNode()->GetObject<MobilityModel>();
      |                                                                         ^
/home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.cc:196:75: error: expected primary-expression before ‘)’ token
  196 |         Ptr<MobilityModel> mobility = GetNode()->GetObject<MobilityModel>();
      |                                                                           ^
/home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.cc:200:29: error: invalid use of incomplete type ‘class ns3::Node’
  200 |                 << GetNode()->GetId() << ","
      |                             ^~
In file included from /home/negar/workspace/ns-allinone-3.38/ns-3.38/build/include/ns3/application.h:1,
                 from /home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.h:4,
                 from /home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.cc:1:
/home/negar/workspace/ns-allinone-3.38/ns-3.38/src/network/model/application.h:32:7: note: forward declaration of ‘class ns3::Node’
   32 | class Node;
      |       ^~~~
/home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.cc:195:22: warning: unused variable ‘data’ [-Wunused-variable]
  195 |     for (const auto& data : m_nodeData) {
      |                      ^~~~
/home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.cc: In member function ‘cv::Mat NodeServer::PerformClustering()’:
/home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.cc:420:32: error: invalid use of incomplete type ‘class ns3::Node’
  420 |         nodeData.id = GetNode()->GetId();
      |                                ^~
In file included from /home/negar/workspace/ns-allinone-3.38/ns-3.38/build/include/ns3/application.h:1,
                 from /home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.h:4,
                 from /home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.cc:1:
/home/negar/workspace/ns-allinone-3.38/ns-3.38/src/network/model/application.h:32:7: note: forward declaration of ‘class ns3::Node’
   32 | class Node;
      |       ^~~~
/home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.cc: In member function ‘void NodeClient::SendNodeData()’:
/home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.cc:485:44: error: invalid use of incomplete type ‘class ns3::Node’
  485 |     Ptr<MobilityModel> mobility = GetNode()->GetObject<MobilityModel>();
      |                                            ^~
In file included from /home/negar/workspace/ns-allinone-3.38/ns-3.38/build/include/ns3/application.h:1,
                 from /home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.h:4,
                 from /home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.cc:1:
/home/negar/workspace/ns-allinone-3.38/ns-3.38/src/network/model/application.h:32:7: note: forward declaration of ‘class ns3::Node’
   32 | class Node;
      |       ^~~~
/home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.cc:485:69: error: expected primary-expression before ‘>’ token
  485 |     Ptr<MobilityModel> mobility = GetNode()->GetObject<MobilityModel>();
      |                                                                     ^
/home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.cc:485:71: error: expected primary-expression before ‘)’ token
  485 |     Ptr<MobilityModel> mobility = GetNode()->GetObject<MobilityModel>();
      |                                                                       ^
/home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.cc:493:24: error: invalid use of incomplete type ‘class ns3::Node’
  493 |     data.id = GetNode()->GetId();
      |                        ^~
In file included from /home/negar/workspace/ns-allinone-3.38/ns-3.38/build/include/ns3/application.h:1,
                 from /home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.h:4,
                 from /home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.cc:1:
/home/negar/workspace/ns-allinone-3.38/ns-3.38/src/network/model/application.h:32:7: note: forward declaration of ‘class ns3::Node’
   32 | class Node;
      |       ^~~~
In file included from /home/negar/workspace/ns-allinone-3.38/ns-3.38/src/core/model/event-id.h:23,
                 from /home/negar/workspace/ns-allinone-3.38/ns-3.38/build/include/ns3/event-id.h:1,
                 from /home/negar/workspace/ns-allinone-3.38/ns-3.38/src/network/model/application.h:23,
                 from /home/negar/workspace/ns-allinone-3.38/ns-3.38/build/include/ns3/application.h:1,
                 from /home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.h:4,
                 from /home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.cc:1:
/home/negar/workspace/ns-allinone-3.38/ns-3.38/src/core/model/ptr.h: In instantiation of ‘ns3::Ptr<T>::~Ptr() [with T = ns3::Node]’:
/home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.cc:81:55:   required from here
/home/negar/workspace/ns-allinone-3.38/ns-3.38/src/core/model/ptr.h:727:16: error: invalid use of incomplete type ‘class ns3::Node’
  727 |         m_ptr->Unref();
      |         ~~~~~~~^~~~~
In file included from /home/negar/workspace/ns-allinone-3.38/ns-3.38/build/include/ns3/application.h:1,
                 from /home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.h:4,
                 from /home/negar/workspace/ns-allinone-3.38/ns-3.38/scratch/EDEN/node.cc:1:
/home/negar/workspace/ns-allinone-3.38/ns-3.38/src/network/model/application.h:32:7: note: forward declaration of ‘class ns3::Node’
   32 | class Node;
      |       ^~~~
make[2]: *** [CMakeFiles/TensorFlow.dir/build.make:63: CMakeFiles/TensorFlow.dir/scratch/EDEN/node.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:2770: CMakeFiles/TensorFlow.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
Finished executing the following commands:
cd cmake-cache; /usr/bin/cmake --build . -j 1 ; cd ..

Upvotes: 2

Views: 45

Answers (1)

Gabriel
Gabriel

Reputation: 136

You're missing include headers in scratch/EDEN/node.cc.

#include "ns3/network-module.h"

Upvotes: 1

Related Questions