{C++ etc.}

Latest Posts
Home | C++ Posts | Linux Posts | Programming Posts | Issue Tracking Posts

Saturday, March 27, 2010

Best IDE for Qt4 Development in Linux

Here's why...
There are several IDE choices to develop Qt4 content in our favorite OS, such as:

Qt Creator 
 Qt Creator has been hyped as being great for not only Qt development, but C++ development as well. So I was pretty exited while the app was being installed via Yast2. Unfortunately, I never got it to run. It quietly crashes and I couldn't find a solution on the internet. Not wanting to go through another download session, I gave up.

Eclipse CDT 
To say that the de facto plugin for Qt4 development in Eclipse CDT,  QtClipse, is still in it's early stages of development, would be and understatement. It offered most of the basic configurations like paths to qmake and moc but didn't offer anything special.

Ever since I remember, I've loathed KDevelop. It's cluttered, the shortcuts are non standard, its auto completion sucked.. you get the point. Anyway, I went ahead and configured my first ever Qt4 app on KDevelop and started working on it. Surprisingly, the build and execute system ran well. I had to edit the Makefile in order to call moc on my classes, but it was a case of copying and pasting the main "moc" clauses and renaming the classes. The documentation got integrated perfectly and creating a new ".ui" class would automatically call Qt Designer. Debugging didn't work though. The application would exit soon after stopping at the first breakpoint. Must be something to do with the Qt event loop.

I didn't try NetBeans yet. My past experiences with it has been a mix between extreme satisfaction to absolute loathing. It's a good overall IDE which consumes a lot of memory. People who are used to developing on NetBeans would definitely prefer this over KDevelop.
I just finished running my first Qt application using NetBeans and it was way better than working with KDevelop. There was no setup involved at all. You just have to create a Qt Project from the "New Project" wizard and you're good to go. It just became my favorite IDE for Qt development :). (I followed this tutorial which gives  great introduction to working on Qt prjects using NetBeans).

From the IDEs that I tried out, KDevelop  turned out to be the best. That is not to say that it is perfect. I'm still looking at other alternatives which would offer an experience like the Qt plugin for Visual Studio under windows.

Wednesday, March 24, 2010

The Newton-Raphson Method and What to do When It Fails

I've been working on a system which uses Newton-Raphson method to solve a system of equations which model the flow of fluids along a channel. We've had great results during initial testing but the system fails miserably in some occasions. This is a limitation which is inherently present in Newton-Raphson iterative method which makes the system diverge. The best solution would be to move to a different numerical scheme which guarantees global convergence.
The other method is to modify the scheme in such a way that convergence is guaranteed ( or the system converges for all valid system parameter values).
While searching for how to achieve this, I came across this page, which gives details of the Damped Newton-Raphson method, which mediates iteration values, hence forcing the system to converge. To use this method to achieve global convergence would take a lot of work and enforce a heavy toll on the processor. It's best to use this iff the normal iteration fails inside a time step.

It's the best option we have at the moment. I would post about the effectiveness of the method after implementing it in our model. 

Newton-Raphson method with example VB code

Monday, March 22, 2010

This application has failed to start because the application configuration is incorrect.. Solution

I came across this error when trying to run an application built with Visual C++ 2010 express on another machine which did not have the .net runtime, Visual C++ redistributable packages installed.

Copy all the DLLs in "[installation directory]\VC\redist\x86\Microsoft.VC.CRT\" to the application directory. These DLLs are needed if the application runs in "Release" mode

Copy all the DLLs in "[installation directory]\VC\redist\Debug_NonRedist/x86/Microsoft.VC.DebugCRT\" to the applciation directory. These DLLs are needed if the application runs in "Debug" mode

Now the application should run without an issue. Install the appropriate (i.e. 2005/2008/2010 etc.)  Visual C++ redistributable package on the target computer for a more permenet solution.

Basic Performance Profiling and Tuning of C++ Programs in Linux

I've just highlighted the basic things you need to get started on profiling. Hopefully it would serve to help developers to refine their methods and go for more complex profiling strategies.

The required tools:
1. Run the tool called callgrind (which is part of the valgrind suite):
valgrind --tool=callgrind [parameters]
2. This would create a file of the format:callgrind.out. You could go through this file using an editor but it's hard to do a proper analysis using only your wits. This is where KCacheGrind comes in.

3. Run KCacheGrind and load the callgrind output file in to it.

Now you would have a visual representation of the calls made by each method displayed as a percentage of the total call count via a rectangular area diagram.


  • If you have a method which you would like to optimize, change the grouping to "Class" and search for the method in order find it quickly.
  • Otherwise, look for the methods which are called the most and optimize them.

5.Also try to lower the call count to these methods by modifying the callers to re-use values

Also Refer:

Sunday, March 21, 2010

Gas Masks and Filters in Metro 2033

If you're playing Metro 2033, there's an important concept that you must come to terms with..
Have plenty of filters and don't let your Gas Mask take damage.
The sooner you get familiar with these things, the easier it would be to play the game.

There's another small problem... You don't get a lot of ammo. What you have is not going to be enough to blast your way out of attacks by blindly spamming bullets. Remember, it's a shooter... but it's not Modern Warfare 2 ;)

Saturday, March 20, 2010

fstream.clear()... How MS takes a working model and breaks it.

I've used fstreams in Linux/Solaris a lot of times and it's always been the same simple model.
  • Open
  • Process
  • Close

Recently, I was working on porting some Linux code to Windows and a strange thing happened (well a lot of strange things happened but this really had me dumbfounded :-|). I found that once an fstream is used to open a file, I can't re-use it even after calling close(). If I created a new fstream instance for each file, everything worked fine.
I found the solution here.
It reads:
It might be surprising to learn that this is in fact by design. The C++ Standard specifies that neither open or close clears the status flags of a stream. As such, the behavior you are seeing is in fact exactly what should happen.

The good news is that this is easy to work around, just add a call to the clear() method of the stream prior to opening it like so:
void open(const char* sFilename) {
m_stream.clear();//clear status of stream, as we're about to reuse it on a fresh file.
int nMode = std::ios::in | std::ios::_Nocreate;
m_stream.open(sFilename, nMode);
if (!m_stream) {
throw "Cannot open file";
m_isOpen = true;

What's bizarre about this is that you should not have to call clear(). "clear()" is a method specified in ios to be used to clear error flags. It's relevance for normal file handling operations is just beyond me.
This is another instance where MS has taken a working system and added unnecessary and irrelevant complexity in to it.

Thursday, March 11, 2010

The Best Free Open Source Web Based Issue Tracker

I've been working on standardizing the development work flow at my company (LHI) and a key feature of this was implementing an Issue tracking service. It would have to run on Linux and not use MS technologies like asp. Additional features like project management and SVN integration were also taken in to account.
First came the evaluation phase where I went through countless blog posts looking for the perfect match. There were many candidates.

were the main ones. Bugzilla went out the window as soon as I visited there site. My PM has had some bad experiences with Trac so it was out as well. Mantis had the "simple" written all over it and I had doubts whether it would hold up in the long run. But when it came to Redmine, we hit the jackpot.

Aesthetics are important. Some "gurus" might argue that as long as it's functioning looks don't matter. But we're talking about a system which would be used by various people from diverse backgrounds and they should not go "aaaaaaaaarrrrrggggghhhhhhhh" when they log in to the system.

Also it should be easy to use. Redmine had the aesthetics part going for it. It wasn't overflowing with artistic touches but had enough stylistics elements to please the eye. The setup on SuSe 11.1 was reletively painless. I had it up and running in 3 hours and I'm just a developer ;-) So far, my experience with Redmine (which has been limited to setting up a single project, adding users and integrating svn) has been excellent.

I haven't played around with customizations and plugins and am still in the process of migrating the site to Apache2 but I think these things would not be difficult. All in all, Redmine is a gem amongst the free and open source issue tracking software arena.