Error in building veins4.4 in Omnet++5.1 rc1

470 views
Skip to first unread message

Xiaofeng Liu

unread,
Feb 28, 2017, 12:27:53 AM2/28/17
to OMNeT++ Users
Hello,

When I tried to build veins4.4 in Omnet++5.1, I got the following error:

veins/modules/mobility/traci/TraCIScenarioManagerLaunchd.cc: In member function ‘virtual void Veins::TraCIScenarioManagerLaunchd::init_traci()’:
veins/modules/mobility/traci/TraCIScenarioManagerLaunchd.cc:91:39: error: ‘class omnetpp::cXMLElement’ has no member named ‘tostr’; did you mean ‘str’?
  std::string contents = launchConfig->tostr(0);
                                       ^~~~~
make[1]: *** [../out/gcc-debug/src/veins/modules/mobility/traci/TraCIScenarioManagerLaunchd.o] Error 1
Makefile:163: recipe for target '../out/gcc-debug/src/veins/modules/mobility/traci/TraCIScenarioManagerLaunchd.o' failed
make[1]: Leaving directory '/home/michael/veins4.4/src'
Makefile:12: recipe for target 'all' failed
make: *** [all] Error 2

in the 

In the beginning I got the version mismatch error, but fixed after I deleted the old 5.0 folder. In my path there is also only 5.1's bin.

Would you please tell me how can fix the problem? Thank you very much!


Xiaofeng Liu

unread,
Mar 2, 2017, 12:07:44 PM3/2/17
to OMNeT++ Users
May I know if Omnet++5.1 supports veins4.4? Thank you very much!

Adil Alsuhaim

unread,
Apr 24, 2017, 12:45:35 PM4/24/17
to OMNeT++ Users
I had the same problem with Veins 4.5 & OMNET++ 5.1. I read on StackOverflow Forums that this is because Veins is NOT compatible with OMNET++ 5.1, and I believe this is because:

In OMNET++ 5.0 source code the file "cxmlelement.h" has the function
Code Snippet #1

std::string tostr(int level) const;

This function is NOT in OMNET++ 5.1

If you look further into OMNET++ 5.0 code, the C++ implementation of that header file. It's in the file  under omnetpp-5.0/src/sim/cxmlelement.cc

Code Snippet #2

std::string cXMLElement::tostr(int depth) const
{
std::stringstream os;
int i;
for (i = 0; i < depth; i++)
os << " ";
os << "<" << getTagName();
cXMLAttributeMap map = getAttributes();
for (cXMLAttributeMap::iterator it = map.begin(); it != map.end(); ++it)
os << " " << it->first << "=\"" << it->second << "\"";
if (!*getNodeValue() && !getFirstChild()) {
os << "/>\n";
return os.str();
}
os << ">";
os << getNodeValue();
if (!getFirstChild()) {
os << "</" << getTagName() << ">\n";
return os.str();
}
os << "\n";
for (cXMLElement *child = getFirstChild(); child; child = child->getNextSibling())
os << child->tostr(depth + 1);
for (i = 0; i < depth; i++)
os << " ";
os << "</" << getTagName() << ">\n";
return os.str();
}




A Workaround solution:
The error in Veins build is the only one I encounter. It occurs in the file TraCIScenarioManagerLaunchd.cc, line 93. If we silenced the error by saying content = "", the build completes, but you run into run-time errors due to malformed XML. So the good news is, that Veins 4.5 issue with OMNET++5.1 is only this function.

So, a solution you can do is to give the compiler what it wants and add that function to OMNET++ 5.1

This is what I did to get it to work:
  • In my OMNET++ 5.1 directory, I edited the file ~/omnetpp-5.1/include/omnetpp/cxmlelement.h by adding the code in snippet #1 in it. I added the function header in line 160, right after the str() function, so it look like this
  • /**
    * Returns a one-line description of the element.
    */
    virtual std::string str() const override;

    //internal : Added by Adil
    std::string tostr(int level) const;


  • Now we need to also add the implementation of this function (Code Snippet #2) into the corresponding .cc file, which is in ~./omnetpp-5.1/src/sim/cxmlelement.cc
    • Basically, we added the old function back to OMNET++ 5.1
  • Now go back to ~/omnetpp-5.1 and "make" OMNET++ again since you have made modifications to it.
  • Now go to your Veins directory and "make". This can also be done in OMNET++ IDE
  • Before you run your Veins example, make sure you run sumo-launchd, because Veins project needs a connection with SUMO. It's something like this
    • ~/veins-4.5/sumo-launchd.py -vv -c ~/sumo-0.29.0/sumo

Other Possible Solutions
You can probably fix this without modifying OMNET++ by adding the code for (Code Snippet #2) somewhere in the Veins 4.5 code, but you need some modifications, and I didn't feel like doing that.


Hope this helps,
Adil

Alfonso Ariza Quintana

unread,
Apr 24, 2017, 2:19:29 PM4/24/17
to omn...@googlegroups.com

You can replace tostr by print

 

 

void cXMLElement::print(std::ostream& os, int indentLevel)

 

std::ostream os;

elem-> print(os, 0);

std::stringstream ss;

ss << os.rdbuf();

std::string str = ss.srt();

--
You received this message because you are subscribed to the Google Groups "OMNeT++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+u...@googlegroups.com.
Visit this group at https://groups.google.com/group/omnetpp.
For more options, visit https://groups.google.com/d/optout.

min wang

unread,
May 13, 2019, 2:47:46 AM5/13/19
to OMNeT++ Users
Good, it works, thank you.

在 2017年4月25日星期二 UTC+8上午12:45:35,Adil Alsuhaim写道:
Reply all
Reply to author
Forward
0 new messages