【原创】ns3 + sumo + ns3gym编译冲突解决方案

Copyright (c) 2024, China,Henan Univercity of Science and Technology
河南科技大学,中国

在搞ndnSIM当毕业设计,ns3 + ndnsim + sumo + ns3-gym编译存在冲突:

                 from ../contrib/ndn4ivc/apps/fgfxf-rsu.cc:25:
./ns3/sumo-TraCIConstants.h:328:21: error: expected identifier before numeric constant
 #define TYPE_DOUBLE 0x0B
                     ^
./ns3/sumo-TraCIConstants.h:328:21: error: expected ‘}’ before numeric constant
./ns3/sumo-TraCIConstants.h:328:21: error: expected unqualified-id before numeric constant
In file included from /usr/include/google/protobuf/message.h:122:0,
                 from ./ns3/messages.pb.h:26,
                 from ./ns3/spaces.h:26,
                 from ./ns3/fgfxf-rsu.h:36,
                 from ../contrib/ndn4ivc/apps/fgfxf-rsu.cc:26:
/usr/include/google/protobuf/descriptor.h:512:24: error: non-member function ‘const string& google::protobuf::name()’ cannot have cv-qualifier
   const string& name() const;        // Name of this field within the message.
                        ^~~~~
/usr/include/google/protobuf/descriptor.h:513:29: error: non-member function ‘const string& google::protobuf::full_name()’ cannot have cv-qualifier
   const string& full_name() const;   // Fully-qualified name of the field.
                             ^~~~~
/usr/include/google/protobuf/descriptor.h:514:29: error: non-member function ‘const string& google::protobuf::json_name()’ cannot have cv-qualifier
   const string& json_name() const;   // JSON name of this field.
                             ^~~~~
/usr/include/google/protobuf/descriptor.h:515:32: error: non-member function ‘const google::protobuf::FileDescriptor* google::protobuf::file()’ cannot have cv-qualifier

解决方案:
先引入sumo,再引入ns3-gym。并解决冲突预定义。

#include"ns3/traci-client.h"
#undef TYPE_DOUBLE
#undef TYPE_STRING
#include"ns3/opengym_interface.h"

请称我为最强!

posted @ 2024-10-11 21:51  范哥范小飞  阅读(74)  评论(0)    收藏  举报