How to use lemon graph library on Omnet++ projects? -


i trying design network(random graph) in omnet++ want parse network nodes using lemon graph library. have installed library , works fine if try compile normal c++ file nodes , edges in graph using command line g++ -o file file.cpp/cc -lemon. when tried 1 of omnet++ project(which has nothing in now) code below

#include <omnetpp.h> #include <iostream> #include <lemon/list_graph.h> using namespace lemon; using namespace std;  class facility : public csimplemodule {     protected:     virtual void initialize();     virtual void handlemessage(cmessage *msg);  };  define_module(facility);  void facility :: initialize(){   }  void facility :: handlemessage(cmessage *msg){  }` 

the include headers in angle brackets(not confused double quotes). when build code following errors:

    description resource    path    location    type ‘class cenvir’ has no member named ‘push_back’  psuc        line 686, external location: /usr/local/include/lemon/bits/graph_extender.h c/c++ problem ‘class cenvir’ has no member named ‘push_back’  psuc        line 687, external location: /usr/local/include/lemon/bits/graph_extender.h c/c++ problem ‘test’ not name type test.cc /ztest  line 9  c/c++ problem invalid use of qualified-name ‘csimulation::getactiveenvir’ psuc        line 69, external location: /home/vijay/omnetpp-4.6/include/cenvir.h    c/c++ problem make: *** [out/gcc-debug//psuc.o] error 1   psuc            c/c++ problem make: *** [out/gcc-debug//test.o] error 1   ztest           c/c++ problem no matching function call ‘lemon::alterationnotifier<lemon::graphextender<lemon::listgraphbase>, lemon::listgraphbase::arc>::add(cenvir&)’   psuc        line 688, external location: /usr/local/include/lemon/bits/graph_extender.h c/c++ problem 

why doesn't omnet++ code compatible lemon graph library?

omnet++ includes macro definition ev in cenvir.h (which included omnetpp.h)

#define ev  (*csimulation::getactiveenvir()) 

because include omnetpp.h before graph_extender.h, macro expanded in library's header file, conflicts use variable name in

ev.push_back(parent::direct(edge, true)); 

a simple solution include graph_extender.h before omnetpp.h, macro not yet defined when graph_extender.h read. if not possible, might have luck manually undefining macro before (and possibly restoring definition after), follows.

#pragma push_macro("ev") #undef ev #include "graph_extender.h" #pragma pop_macro("ev") 

Comments