How to use NetworKit as a library in OMNeT++? - c++

I am trying to build the C++ Core of NetworKit and I would like to use it as a library in OMNeT++. I followed the instructions from the README file to build the code with cmake and make all. Then, I tried to follow the instructions from the Use NetworKit as a library section, but the examples presented there are not consistent with the source code. In particular, the directory NetworKit/graph does not contain the Graph.h file. There is a Graph.hpp file, but in another directory. Also, the LibDemo.cpp file is missing. Is the README file outdated or I am missing something here?
EDIT
This is an update to my post above. Apparently the README file is not up to date. In any case, I built the C++ Core of NetworKit. I included the library in my OMNeT++ application as follows:
#include <graph/Graph.hpp>
In OMNeT++, in my project Properties | OMNeT++ | Makemake, and then selecting src | Options | Custom, I added the following:
INCLUDE_PATH += -I/path/to/networkit/include/networkit
LIBS += -L/path/to/networkit/build_lib -lnetworkit
When I build my OMNeT++ project, I get the following error:
/path/to/networkit/include/networkit/graph/../Globals.hpp:42:14: error: expected unqualified-id
const double PI = 2.0*std::acos(0);
^
/path/to/omnetpp-5.4.1/include/omnetpp/simkerneldefs.h:47:19: note: expanded from macro 'PI'
#define PI 3.141592653589793
^
Can anyone help me with this? Thank you in advance!

You're correct, the documentation is out of date, LibDemo.cpp was deleted here: https://github.com/kit-parco/networkit/commit/a5b2c1f0c9336e783c8fb0cd956326d960451914
If you want an older version where this part of the doc is still valid, that would be version 4.2 which is the last version with this file. Somebody made a clone of that version here for some reason: https://github.com/SharafMohamed/NetworKit

Related

"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.

QT missing binary operator before token "(" Error

I am using QT 5.7.1 and trying to build this experimental project.
But when i try to build, i get this error in qchar.h file:
D:/QT2/5.7/mingw53_32/include/QtCore/qchar.h:333:24: error: missing binary operator before token "("
#if QT_DEPRECATED_SINCE(5, 3)
There is only one version of QT is installed right now, and i controlled the file path of qchar.h. It is in QTCore folder. I tried google search based solutions but i could not build.
I have been googling for 2 days now, no solutions yet. I appreciate if anyone helps.
I found that file "signal.h" hides a file in QT include directory. I renamed the "signal.h" file to "QRPsignal.h" and solved the problem.
Also, when you rename "signal.h" file (of QRadioPredict) using QT, QT renames original include file in its own directory too. You should rename again the original file (of QT) to "signal.h".
In case anyone trying to build QRadioPredict on Windows, should keep this in mind.
Thank you for your suggestions.

missing include from v4l2, linux vs uapi/linux

I'm learning the v4l2 API for configuring video devices through v4l2-ctl. The code samples from ages ago are really out of date and some of the defines don't work anymore. There is a new method of requesting everything for the API from the kerhel which is shown in v4l2-utils. I'm trying to incorporate some of the code from v4l2-utils into my code. However, I'm getting an error from the compiler:
camera.hpp:1038:8: error: 'struct v4l2_ext_controls' has no member named 'which'
ctrls.which = V4L2_CTRL_ID2WHICH(qctrl.id);
And:
camera.hpp:1038:43: error: 'V4L2_CTRL_ID2WHICH' was not declared in this scope
ctrls.which = V4L2_CTRL_ID2WHICH(qctrl.id);
The field and define are in a file located in the linux source tree: /usr/src/linux-4.6.3-gentoo/include/uapi/linux/videodev2.h, but that file is not included when I specify:
#include <linux/videodev2.h>
What is the voodoo to get the compiler to include the correct file?
I've been studying the v4l2-utils source but can't figure it out.
Thanks much.
The file located in /usr/include was out of date. I had the headers installed for kernel 4.3 and needed the ones from a later version. The solution for my gentoo install was to add a keyword for sys-kernel/linux-headers and install the latest headers (4.7).
It turns out that the UAPI file becomes the headers when installed into /usr/include. I could probably have accomplished this with make headers_install in my /usr/src/linux directory as well, but I'm not sure whether that is more "correct" than installing the linux-headers ebuild. I worry about conflicts.
Hope this helps someone else...

Compiling C++ file with CMAKE (Unrecognized '-rdynamic')

I am trying to add a single C++ file to a working CMAKE project.
The project is building fine when I only have C files in the project. However, as soon as I add a cpp file to the ADD_EXECUTABLE section of CMakeLists.txt I get the following error: arm-none-eabi-gcc: error: unrecognized command line option '-rdynamic'.
Does anyone have any idea what might be going on here? Or what I could do to fix it?
Thanks so much for the help!
PS - I have a section at the top of the CMakeLists.txt that says SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS) # get rid of -rdynamic, but it doesn't seem to be doing that.
Check the armgcc.cmake (or equivalent). I found a field there named CMAKE_SYSTEM_NAME and CMAKE_SYSTEM. These need to be renamed to 'Generic'. This took care of the problem for me.

Qt - qstring.h include string error

I am an admitted noob when it comes to Qt and compiling on linux, so forgive me if this is a simple mistake.
I am attempting to compile a program on Ubuntu 14.04 LTS using:
qmake myprogram.pro && make
This application uses Qt4. I am getting a strange error that appears to originate in Qt itself.
In file included from /usr/include/qt4/QtCore/qobject.h:48:0,
from /usr/include/qt4/QtCore/qiodevice.h:46,
from /usr/include/qt4/QtCore/QIODevice:1,
from src/qt/fervor/quazip/zip.c:22:
/usr/include/qt4/QtCore/qstring.h:54:20: fatal error: string: No such file or directory
# include <string>
^
I am guessing this is an environment issue rather than an issue with my program. I have poked around the web and some people have suggested c++ build essentials aren't installed. I have verified the Ubuntu build-essentials package is installed.
Thanks in advance!
EDIT
So I went into the core qt header file, qstring.h, and found a constant that needed to be defined for my environment (QT_NO_STL). When I define that, I get a new error:
In file included from /usr/include/qt4/QtCore/qlist.h:45:0,
from /usr/include/qt4/QtCore/qobject.h:50,
from /usr/include/qt4/QtCore/qiodevice.h:46,
from /usr/include/qt4/QtCore/QIODevice:1,
from src/qt/fervor/quazip/zip.c:14:
/usr/include/qt4/QtCore/qiterator.h:50:79: fatal error: new: No such file or directory
# include <new>
The credit really belongs to #KubaOber, but in the interest of helping others I am posting the answer that solved my problem.
Turns out that I added a dependency (library) and didn't re-create the .pro file with qmake -project.
Thanks!
In my case it worked by just adding the following in the <project>.pro file:
CONFIG += qt
OR add instead:
CONFIG += qt
QT += svg