Let OMNet++(OMNetpp) support c++11 or c++0x standard

Adam posted @ Sun, 05 Jan 2014 00:59:07 +0800 in OMNet++ with tags c++ c++11 OMNet++ , 4980 readers

There're a lot of people asking how to customly define c++ compile flags (CXX_FLAGS) under OMNet++ 4 (OMNetpp 4), but don't really get an answer.

Here is the answer now. First follow my instruction and then I'll explain the reason.

Important: These are instructions under Linux. However, it's still very easy to port these instructions to Windows. Try it yourself.

  • mkdir -p ~/.omnetpp/
  • cp $omnetpp_root/Makefile.inc ~/.omnetpp/
    • if you do not know about the omnetpp_root environment variable, you probably have a false setup of OMNet++.
  • vim ~/.omnetpp/Makefile.inc
  • add -std=c++11 to CFLAGS_DEBUG and CFLAGS_RELEASE
  • You may edit the Makefile.inc as you wish as long as you know what you're doing.
  • vim ~/.bashrc
  • Append export OMNETPP_CONFIGFILE="~/.omnetpp/Makefile.inc" to the end of your ~/.bashrc file
  • source ~/.bashrc
  • Finally, rebuild your project either with Eclipse or opp_makemake.
  • Enjoy!

Reasons Here:

If you examine the Makefile generated by opp_makemake carefully, something may catch your eyes.

# Pull in OMNeT++ configuration (Makefile.inc or configuser.vc)

ifneq ("$(OMNETPP_CONFIGFILE)","")
CONFIGFILE = $(OMNETPP_CONFIGFILE)
else
ifneq ("$(OMNETPP_ROOT)","")
CONFIGFILE = $(OMNETPP_ROOT)/Makefile.inc
else
CONFIGFILE = $(shell opp_configfilepath)
endif
endif

This part of Makefile code pull in the configuration defined by the users (You!).

Where to pull?

The environment variable: OMNETPP_CONFIGFILE

so ... set it and enjoy whatever you like, either c++11 or openmp or valgrind, etc.

 

link: http://blog.modest-destiny.net/omnetpp/2014/01/05/Let-OMNet++(OMNetpp)-support-c++11-or-c++0x-standard/


Login *


loading captcha image...
(type the code from the image)
or Ctrl+Enter