Ns3 adding a new module-- gcc not finding included headers - c++

I am trying to add a new custom module to NS3Network Simulator 3 and I am having trouble making the header files of the module visible to the compiler.
Here is what I did:
1.I followed thisguide to add a new noc module using the createModule script.
2.I went on and copied my module files into the new created noc directory and made waf(the build system ns3 uses) aware of my new files through editing the wscript file.
3.It is my understanding that with all this set up(I probably wrong) that with this set up,running the waf commands to rebuild ns3 should rebuild ns3 with my new module.
To build I give the following commands:
./waf clean
./waf configure --enable examples
./waf build
The system goes on and builds ns3 and when it gets to my noc module it throws errors about objects of a Scalar Class not being defined in the scope.This usually means that I haven't included the header files but I have tried to copy them with other module files and included them with statements like #include "nstime.h" .With this the problem persisted. I tried copying the header with the definition of my class in the /usr/include directory and inlcuded it with #include and the problem is still there.
I realize this is a long post ,I am sorry but I would really appreciate it if somebody helped point out what I am missing.Thank you for your time.

You should also make sure in your wscript file that you add the dependencies of your module to other ns-3 modules as explained here.

Related

QT moc class can not find the original file, despite it being in correct directory

I'm trying to build qt project but I keep getting error about no existing header in moc object moc_SerialPortManager.cpp. I moved with bash to that directory and used cd cmd with the path written in mock object and it leads to the correct directory. Does anybody have a slightest idea how to resolve it? At this point it's quite big project so just please tell me what could I publish to make this easier for you?
I have it all on git https://github.com/Orpiczy/AcornScanner/compare/fronAndBackJoin if you wish to check it out
I'm using Mingw compiler 8.1.0 64-bit for c++ and Qt 6.2.0, I'm working on windows10
moc_SerialPortManager.cpp
#include <memory>
#include "../../../../../../source/controllers/LowLevelFunctionality/DeviceController/ProfilometerManager/SerialPortManager.hpp"
#include <QtCore/qbytearray.h> ...
logs
E:\Dokumenty\AiR_rok_4\S7\EngineeringThesis\AcornScanner\cm\cm-lib\build\windows\gcc\x64\debug.moc\moc_SerialPortManager.cpp:10: error: ../../../../../../source/controllers/LowLevelFunctionality/DeviceController/ProfilometerManager/SerialPortManager.hpp: No such file or directory
........\AcornScanner\cm\cm-lib\build\windows\gcc\x64\debug.moc\moc_SerialPortManager.cpp:10:10: fatal error: ../../../../../../source/controllers/LowLevelFunctionality/DeviceController/ProfilometerManager/SerialPortManager.hpp: No such file or directory
#include "../../../../../../source/controllers/LowLevelFunctionality/DeviceController/ProfilometerManager/SerialPortManager.hpp"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Note that the layout of your repository differs from your local filesystem:
.../debug/.moc/
vs.
.../debug.moc/
Therefore the relative path steps up one level too much and results in a non-existing path.
It is generally considered bad practice to put automatically generated files (i.e. moc files) under version control. I would assume if you remove the whole build directory and build again you will be fine.

Protoc Output Directory Issue - No Such File or Directory

I recently finished the basic tutorial for C++ here and wanted to set up a project based on the proto files from here. I followed a similar directory structure as the tutorial and changed up the CMakeLists.txt file to accommodate the new files.
I'm currently trying to just compile the manager.proto file. I was able to compile the file and get my server/client files, however the files are being outputted within cmake/build/minknow_api rather than the expected cmake/build folder. This meant the make command would return the error:
clang: error: no such file or directory: '/Users/name/Documents/grpc/examples/cpp/minknow_api/cmake/build/manager.grpc.pb.cc'
clang: error: no input files
I read that it was because protoc outputs based on the imports of the proto file, i.e the file comes with import minknow_api/device.proto for instance. I copied the files from within the cmake/build/minknow_api into cmake/build/ and reran make and it seemed to work, however, the C++ file imports as expected are searching within a minknow_api directory, meaning I'd have to manually edit these imports to look within the current directory instead of to then compile successfully.
I've tried experimenting with trying to get rid of the minknow_api from the proto imports, however had no luck and only got more import issues during compilation. It seems some files have the same names for messages etc, which means I had to keep the minknow.somename as the package so I can thus distinguish in the files which imported values I wanted to access. I've also tried moving files into their own directories like instance.proto which has package minknow.instance would go inside of instance directory, but still no luck.
I was wondering if anyone could figure out how to get rid of the minknow_api out of my proto imports properly so that I won't get these import and output directory issues down the track?

FreeRTOS.h file not found - VS Code for Mac despite includePath modified & all filed in project folder

I am trying my best to include FreeRTOS into a new Project on VS Code for Mac.
I have created a directory for my project, added a main.cpp, configure the default build task for C/C++ clang. I have also created the c_cpp_properties.json.
My project consists of three folders; 'src' containing my main.cpp, and 'FreeRTOS' containing all of the source files for FreeRTOS (include & portable folders), and 'Demo' containing a demo app built for the CORTEX_ATSAM3X_Atmel_Studio board (that comes with the FreeRTOS download).
In my main.cpp file, I have an empty main function, that I can build successfully. The minute I try to add #include <FreeRTOS.h> to main.cpp, I am given the error FreeRTOS.h file not found.
What is interesting, is the first time I try to build, it recognises FreeRTOS.h, and the error I see is that it cannot find a file included in the FreeRTOS.h. To remedy this, I add the specific subdirectory to c_cpp_properties. I rebuild and then it shows me another file it cannot locate. So I work again manually amending another subdirectory. After 5 or 6 times, suddenly it fails to find FreeRTOS.h. When I delete all of the includePath entries except "${workspaceFolder}/**" I cannot get back to my starting point.
I have spent the last two days stuck on this, reading forums, starting my process again and I still cannot see where I am going wrong.
Probably I run into the same issue.
The problem was FreeRTOSConfig.h contains this definition
#define CMSIS_device_header "stm32h7xx.h"
which is next used in freertos_os2.h header (only):
#include CMSIS_device_header
and that is where build gets confused. It is not the perfect solution but removing the CMSIS_device_header variable and specifying stm32h7xx.h header directly in freertos_os2.h file solved my problem.

"unsupported/Eigen/CXX11/Tensor: No such file or directory" while working with TensorFlow

I'm trying to use tensorflow as a external library in my C++ application (mainly following this tutorial). What I done so far:
I have cloned the tensorflow reporitory (let's say, that the repo root dir is $TENSORFLOW)
Run /.configure (which all settings default, so no CUDA, no OpenCL etc.).
Build shared library with bazel build -c /opt //tensorflow:libtensorflow_cc.so (build completed successfully)
Now I'm trying to #include "tensorflow/core/public/session.h". But after including it (and adding $TENSORFLOW and $TENSORFLOW/bazel-genfiles to include path), I'm receiving error:
$TENSORFLOW/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1:42:
fatal error: unsupported/Eigen/CXX11/Tensor: No such file or directory
There is a github issue created for similar problem, but it's marked as closed without any solution provided. Also I tried with master branch as well as v.1.4.0 release.
Do you happen to know, what could cause this kind of problem and how to deal with it?
I (and many others) agonized over the same problem. It probably can be solved using bazel but I don't know that tool well enough and now I solve this using make. The source of confusion is that a file named Tensor is included and it itself includes a file named Tensor, which has caused some people to wrongly conclude Tensor is including itself.
If you built and installed the python .whl file there will be a tensorflow directory in dist-packages and an include directory below that, e.g. on my system:
/usr/local/lib/python2.7/dist-packages/tensorflow/include
From the include directory
find . -type f -name 'Tensor' -print
./third_party/eigen3/unsupported/Eigen/CXX11/Tensor
./external/eigen_archive/unsupported/Eigen/CXX11/Tensor
The first one has
#include "unsupported/Eigen/CXX11/Tensor"
and the file that should satisfy this is the second one.
So to compile session.cc that includes session.h, the following will work
INC_TENS1=/usr/local/lib/python2.7/dist-packages/tensorflow/include/
INC_TENS2=${INC_TENS1}external/eigen_archive/
gcc -c -std=c++11 -I $INC_TENS1 -I $INC_TENS2 session.cc
I've seen claims that you must build apps from the tensorflow tree and you must use bazel. However, I believe all the header files you need are in dist-packages/tensorflow/include and at least for starters you can construct makefile or cmake projects.
Slightly off-topic, but I had the same error with a C++ project using opencv-4.5.5 and compiled with Visual Studio (no problem with opencv-4.3.0, and no problem with MinGW).
To make it work, I had to add to my root CMakeLists.txt:
add_definitions(-DOPENCV_DISABLE_EIGEN_TENSOR_SUPPORT)
If that can help someone...
the problem was actually in the relative path of the header file taken in the Tensor file.
installed path for Tensor is /usr/include/eigen3/unsupported/Eigen/CXX11/Tensor
but mentioned in the Tensor file is "unsupported/Eigen/CXX11/Tensor"
So there should be an entry upto /usr/include/eigen3/ in the project path to run this correctly so that it can be used.

(C++) How can I test the new application in MOOS-ivp?

I've got a problem with compiling my basic code with MOOS-ivp.
I made main.cpp, simpleApp.cpp and simpleApp.h from documentation, where should I put it to build it with moos? In docs there is note about launching MOOSDB and uMS - ok, but there is not any option to find path to my .cpp file. Is there any default path? Maybe should I compile it firstly with gcc?
I'll assume you know some basic information about MOOS or are taking the MIT 2.680 course and know some of the terminology talked about in the introduction lab.
The recommended way to build external MOOS is to have moos-ivp and moos-ivp-extend in a directory next to each other. You should run GenMOOSApp_AppCasting in the moos-ivp-extend/src directory and add your new project to the CMakeLists.txt file in the same directory. Then, use the included ./build.sh script to build your executables, and add the directory it makes to your $PATH.
Finally, you should be able to run your mission with your new MOOS app.