The OpenSource Eclipse Kepler C++ KMix productivity boost

Today I’d like to share a revelation with you:

Developing C++ can actually be fun.

10reasons_6

How you work can define your productivity

In the next sections I will tell you a bit about how I develop KMix today, and why the newest toolchain gave me a productivity boost. As a peek ahead, this post is mainly about developing KDE applications with Eclipse.

If you just came across this post via searching for Eclipse,  C++ and cmake, then you might want to directly head to the practical example at the end of this post.

The core message is that the environment you work with can have a very high impact on productivity. As an example, see the picture to the right from my office: Isn’t this a more comfortable environment than – a cubicle? OK, I was talking about productivity, wasn’t I? So lets forget the image quickly. 😉

The C++ nuisance and rant

Honestly, most of the time  C++ development is a nuisance for me. For a better understanding, you should know that I am a 95% Java developer nowadays. And if you do a lot of Java, C++ is full of strangeness:

CMake and Eclipse as a rescue boat

If you get good tool support, C++ can still be a very good language. CMake helps a lot. For the source code editor it is more complicated: In the past I used every viable tool for KMix development, including misc versions of emacs, vi, aXe, kate, KDevelop and Eclipse CDT. All have their own strengths, but I could use none of them well for KMix development. Then recently I did a new shot at Eclipse CDT (Kepler based), and I am actually delighted.

  • The CMake integration now works flawless for me
  • The C++ indexer is super-fast and reliable (a massive weakness in former versions)
  • Navigation for header to source and back finally works and is very fast. Signals and Slots are parsed correctly and can be navigated.
  • Call hierarchies work great most of the time. In some C++ specific constructs they do not work, but using “references” is a good alternative.
  • Even the strangest #define and #include constructs work as expected.
  • Warnings, Errors, TODO’s and so forth are shown by default very appropriately in the editor and the other Eclipse Views. Very comfortable if one is accustomed to Eclipse.

KMix is a pretty small project, so mileage may vary for your project. Still I recommend to try “Eclipse Kepler CDT” if you have not done so recently. It brought back the fun in development for me.

Practical guideline for developing KDE applications with Eclipse

The basic step to build an Eclipse project is:

cd kmix-git-trunk.obj; cmake -G”Eclipse CDT4 – Unix Makefiles” ../kmix-git-trunk

As a reference, kmix-git-trunk.obj is where I build kmix, kmix-git-trunk is the GIT checkout. After that you can import the project into Eclipse. Run the above command again whenever required and refresh the whole source tree in Eclipse (F5) after that. Personally I am using Eclipse only to edit the source code, to navigate and browse quickly through sources, headers and includes. Everything else I am doing from a console window, like building, running, debugging and version control (GIT).
(Update 2013-12-16: Debugging works fantastic from within Eclipse, so I will use that from now on)

Thanks if you read until the end. If you have any input, experience or feedback, please leave a comment.

Christian

3 responses to this post.

  1. Posted by Abdurrahman AVCI on December 11, 2013 at 9:13 am

    Plain editors like vi, kwrite, kate lacks a lot of features, KDevelop was overly complicated when I last tried (a couple of years) and I wasn’t even able to install cdt for eclipse (this was like 5-6 years ago more or less).

    I have also tried Dev-C++ and Code::Blocks and didn’t fancy them much either.

    On windows, visual studio is bearable too, but it lacks some headers (unistd.h etc.), has a slower adoption rate for new standarts like c++11 etc.

    Finally, QtCreator… I have been using it since inception and IMHO it is the best tool for Qt/C++ development. I have been using it for many projects on linux and windows, and it has the lowest rate of defects 🙂

    My dream IDE would be to have a clang based, cross-platform IDE with native cmake support.

    Reply

  2. Actually, ‘volatile’ is also a pretty useless keyword in java 🙂

    Reply

    • ‘volatile’ useless in Java? Au contraire!
      It was true for Java 4. Starting with Java 5, volatile is a crucial part in multi-threaded code. Serves as a full memory barrier (“happens-before”), while reducing the number of locks at the same time.

      Reply

Leave a comment