So if I’m going to take the plunge to learn c++ just so that I can use the Omnet simulator, I better have some decent tools to figure out what’s going wrong.
Since it’s likely that I’ll be doing some development on my windows machine and some on Ubuntu boxes, I’m opting for an Eclipse-based development environment. Unfortunately, it’s not so trivial to get everything working together, so here I am with yet another guide to what I’ve done to get my setup working. I hope it helps someone else out there…
Eclipse and CDT
Downloading and installing Eclipse, and getting a couple “Hello World” apps up and going is the first step. Go do this and come back
OMNet Install
The OMNet install should be pretty straight forward. It’s likely that you’ll need to use the setup tool (cygwin:setup.exe, ubuntu:apt-get) again to install some missing packages, but the configure script it pretty good about telling you what you’re missing.
./configure
make
Omnet dependency: BLT
I never did get the developer extensions for BLT installed, but I did find an executable for BLT on the sourceforge site. This was close enough for me. I just dropped the (renamed) blt.exe into my bin directory that was already in my path.
Omnet dependency: giftrans
Again, I never did get this installed ‘correctly’, but I did find an executable version somewhere on the web and dropped it into my bin directory.
Omnet Verification
Ok, so now OMNet should be working, but we need to verify that first. Go to the tictoc sample and run it. This should work no problem.
cd samples/tictoc/or
./tictock.exe./tictoc
Update OMNet to include debug information
Before going too much further, take a second now to edit the configure.user file. Uncomment this line:
CFLAGS='-g -Wall'" and
and comment out the others. Then recompile Omnet again to include these options.
./configure
make clean
make
Create the Eclipse Project
First, create a new project:
- From the workbench,
File -> New -> C++ Project - Project Name: tictoc
- Project Type: Makefile project
- Toolchain: — Other Toolchain –
- Finish
Then we need to get the code in there… Copy the contents of the tictoc sample directory into the new tictoc directory under your eclipse workspace directory. Then clean it, just to be sure…
cd /c/dev/eclipse-workspace/tictoc
cp /c/bin/omnetpp-3.3/samples/tictoc/* .
make clean
If you try to build, eclipse will complain that there’s no rule to make target `all'. This is because eclipse by default tries to run “make all” rather then just “make”. Fix this:
- From the workbench,
Project -> Properties - On left: C/C++ Build
- On Right: “Behaviour” tab
- Clear the text field next to “build (incremental build)”
- Ok
Now you should be able to build. Clicking the little hammer icon should cause the console to start scolling with make output, or report that `tictoc is up to date’.
Try debugging!
Before we start, throw a break-point on the send(msg, "out"); line of txc1.cc. When the debugger stops on this line, you’ll know you’re done.
Now, we need to set the binary parser option so that eclipse recognizes the executable that we are producing:
- From the workbench,
Project -> Properties - On left: C/C++ Build -> Settings
- On Right: “Binary parsers” tab
- Check the “Cygwin PE Parser” option
- Ok
Now create the debug configuration:
- From the workbench,
Run -> Open Debug Dialog - On left: C/C++ Local Application
- At the top: The ‘new’ icon
- On Right: Project “tictoc”
- On Right: C/C++ Application: “tictoc.exe” (hopefully this is filled in for you already)
- Debug!
If you’re using Cygwin, you’ll likely run into the problem below. Otherwise, you should be done. Congrats!
Can’t launch debugger: …No symbol table is loaded…
(I think this only applies to Cygwin users)
This was the most aggravating bug to fix, mostly because the message boards all looked like this:
Newbie: I'm getting this error: ....
"Expert": Try gdb.
"Expert": Try the -g option
"Expert": Try google first, n00b!
Gee... you think I should google stuff before posting a question? Come on people. Turns out that the -s option to the linker is hard-coded into the opp_makemake script. The -s does the following:
Remove all symbol table and relocation information from the executable.
So, golly, it's OMNet's make files that are to blame... not the newbie... go figure.
So to fix this, you can either remove the option from Omnet's configure script (permanent), or you can always remember to remove it from the generated Makefile (not permanent). I opted for the later since (a) it'll be obvious when I forget and (b) my omnet install will be as standard as possible.
- Open the generated Makefile in the tictoc directory
- Find the line that defines "LDFLAGS"
- Remove the option "-s"
- Save
- From the workbench,
Project -> Clean... - From the workbench,
Project -> Build Project - From the workbench, Click the debug button
Thanks man, it did help me to debug OverSim