Official website for Linux User & Developer
FOLLOW US ON:
Nov
15

Open source programming for beginners

by Kunal Deo

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:

$ sudo add-apt-repository ppa:kubuntu-ppa/ppa
$ sudo add-apt-repository ppa:kubuntu-ppa/backports

Install KDE Development libraries

$ sudo apt-get install kde-devel

Install KDevelop 4 and supporting libraries

$ 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://gitorious.org/kdevelop/kdevelop-pg-qt.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.

$ svn co svn://anonsvn.kde.org/home/kde/trunk/playground/devtools/kdevelop4-extra-plugins

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 follow us
Pages: 1 2 3 4 5 6
  • Tell a Friend
  • Follow our Twitter to find out about all the latest Linux news, reviews, previews, interviews, features and a whole more.
    • grep

      Personally I’d hesitate telling a beginning programmer to use the system() function call. But if I mentioned it, I’d at least explain that it could have grave system security implications.

      For instance, the command that the system() function call executes may run at the same privileges as the program containing the system() function call. This could be bad news if your program somehow gets “root” privileges (via the Set-User-ID or Set-Group-ID settings, or otherwise).

      Next, the program containing the system() function call may not execute the command that you think it will. For instance, using your example ( system(“ls -l”) ), if a cracker can somehow get you to execute your program with a bogus executable file called “ls” in the current directory, then what’s actually executed will be what the cracker intended, but not what you expected. Probably not the best example, but you get the idea. Using a full path name in the parameter for the system() function call may help mitigate this problem, at the possible expense of cross compatibility, but not necessarily eliminate it.

      Admittedly, there’s a time and place to use any of the hundreds of Linux function calls, but a good programmer will (or should) be aware of the implications of those that they chose.

    • Pingback: LXer: Open Source programming for beginners - oBlurb

    • Ken Jennings

      SQL in a C program is a LOT more simple when using a database that provides an embedded SQL compiler. (PostgreSQL for one.)
      Not the end-all-be-all of perfect examples, but here’s a sample:
      http://www.kenjennings.cc/st/stprgux.html
      http://www.kenjennings.cc/st/prg/ux/test_pgc.tar.gz

    • Pingback: Linux User & Developer issue 93 is out now! | Linux User

    • Pingback: Introduction to Linux / Newbies Guide

    • Pingback: Linux coding tips for newbies « 0ddn1x: tricks with *nix

    • Pingback: Nikon D3100 Dslr Reviews

    • Morgan

      A new book covering the basics: Programming From Scratch by Gary Crandall available here http://www.perfscipress.com/programming-from-scratch/

    • http://www.howtouseachainsaw.com/item-poulan-pro-50cc-gas-22-in-chain-saw-with-case-pp5020av-new_280924888864_US_0.html buy chainsaw

      It really is really a good plus practical little bit of info. I’m fulfilled you provided this handy facts along with us. Remember to keep us current this way. Appreciate your spreading.