Open source programming for beginners

Sometimes even experienced developers can be a bit overwhelmed by Linux’s extensive development capabilities. Sit back and soak up these tips to become a smarter and more productive Linux developer overnight…

KDevelop 4 Playground plug‑ins
KDevelop 4 is a multi-language IDE for KDE. It supports most of the modern IDE features and has strong support for C++. It features built-in templates for developing KDE and Qt applications. KDevelop 4 uses CMake as its default build system for KDE and Qt applications.

KDevelop 4 is a plug-in-based IDE. Almost every feature provided in KDevelop 4 is a plug-in, be it a project-type support or the SVN support. By default it ships with a set of stable plug-ins for the sake of a stable KDevelop experience. However, if you like to live on the edge, you can try experimental KDevelop plug-ins from the KDE Playground.

These plug-ins are available in the source form and hence you will require KDE development libraries to build and use them.
To install KDevelop 4 and KDE development libraries, you will need to enable the following repositories:
[sourcecode language=”cpp”]$ sudo add-apt-repository ppa:kubuntu-ppa/ppa
$ sudo add-apt-repository ppa:kubuntu-ppa/backports
Install KDE Development libraries
[sourcecode language=”cpp”]$ sudo apt-get install kde-devel
Install KDevelop 4 and supporting libraries
[sourcecode language=”cpp”]$ sudo apt-get install kdevelop
$ sudo apt-get install kdevplatform-dev
$ sudo apt-get install kdevelop-dev
$ sudo apt-get install flex bison
$ git clone git://
$ cd kdevelop-pg*
$ mkdir build
$ cd build
$ cmake -D CMAKE_INSTALL_PREFIX=/usr ..
You can obtain the plug-ins using KDE Public SVN Servers.
[sourcecode language=”cpp”]$ svn co svn://
Some of the plug-ins in the Playground are the support for Automake, BazAR, C#, Git, CSS, Java, Mercurial, Python, qmake and SQL.

Best practices for writing cross platform applications

1. Go the interpreted route where possible: Interpreted programming languages such as Python and Ruby are far more portable than compiled programming languages. With support for GUI toolkits such PyGTK and PyQT, you can also develop high-quality desktop applications. These application can be ported as is and won’t even need recompilation.

2. Use a cross-platform build system: Makefiles are not portable. Each platform has its own makefile format. Cross-platform build systems like CMake work around this issue by generating platform-specific makefiles on each given platform.

3. Stay away from static linking: Always compile your applications to use a shared (or dynamic) library. Dynamic linking makes executable files smaller and saves disk space, because one copy of a library can be shared between multiple programs. Most operating systems also provide a virtual memory mechanism which allows one copy of a shared library in physical memory to be used by all running programs, saving memory as well as disk space. Furthermore, shared libraries make it possible to update a library without recompiling the programs which use it (provided the interface to the library does not change).

4. Avoid using C++ templates: Avoid using C++ template libraries unless it is a known cross-platform library such as Boost. Also, use this when calling methods on a templatised base class.

5. Conditional compilation: Use #ifdefs to perform conditional compilation based on the currently running platform.

6. Carriage returns: Pay attention to the difference between the text files of different platforms. You must use the appropriate carriage returns on the relevant platform.

7. Case of filenames: Pay attention to the filename cases. For example, MyHeader.h and myheader.h are the same on Windows, but different on Linux.

Linux is an amazing developer platform, not just for writing PC or enterprise applications but also for writing applications for devices like smartphones, TVs, set-top boxes and so on. The possibilities are endless here. Not everything was covered in this article due to the space constraints, but we will showcase more developer tips in forthcoming Linux User & Developer articles.

[twitter username=”linuxusermag”]