Writing C code on GNU/Linux

gcc, automake and IDE's

"I'm new on linux and i really want to use it as my workstation."

You need to have good experience of GNU/Linux before starting to develop code. You need to understand the filesystem, the GUI's (at least the main two), CVS, automake and the main C library: libc.


It's all about portability, you need to understand different distributions so that you can appreciate how to write code that works on all GNU/Linux systems, not just yours. The target is far more challenging here because there are so many different implementations of the system itself.

You also need to understand licencing issues - read the GNU General Public Licence and understand what it means, for you, as a developer.


50% of all GNU code is under the GNU GPL, there are good reasons for that and therefore the likelihood is that your chosen project will either be 100% GPL or contain GPL plus other free software licences.

As a developer, you must respect the freedom of the code that provides your system. Don't expect to keep your source code to yourself - the licences for the programs and libraries that you use and link into your project will require some form of open source.

The GPL is there to protect YOU from having your code sucked into a proprietary program that doesn't release it's modifications back to the community, ala MS.

"How do i compile my C/C++ source in linux?"

Small test tools, direct from gcc.

gcc myfile.c

gives you an executable a.out in the current directory. (or more likely a compiler error.)

You can write simple Makefiles yourself for Hello World type test programs, even use multiple source files. There are good books for this:


and lots of websites.


Any of your existing MS C code will need the entire GUI stripping out - none of that is transferable to any of the window managers or desktop environments in GNU.

(GNU is the bulk of the operating system, Linux is the kernel.)

Re-learning either Qt (for KDE) or Gtk (for Gnome) is a large undertaking and you will need to set time aside to learn how the GUI's operate.

Start with www.kde.org and www.gnome.org

A good test is to load up the source for one of the programs that you already know and use. Then try and follow it! Use the website for the program too - many use Doxygen which can convert source code into developer documentation.

Take a look at the Doxygen output for my code:


As far as an IDE, I've used two, Anjuta and KDevelop.

Which one you use depends really on which one imports your chosen project the most easily. Anjuta copes with my main project, GnuCash, but KDevelop doesn't. Anjuta may have a Gnome bias, KDevelop is certainly very biased towards KDE. There are others, Kylix for one, but not all handle C as well as my main two.

You can see some of the code I produce in C on GNU/Linux here:


This page attempts to address some of the guidelines for starting in C on GNU/Linux:


Substitute any large program for GnuCash in that example.

There's a general guide to working with larger programs:


Don't re-invent any wheels, get experienced in GNU/Linux, learn the tools that exist and join a team. It's unlikely that you are working on code that nobody else hasn't already considered and probably started.

Take a look through SourceForge for ideas. Also, look at www.freshmeat.net and see if others are releasing code that matches what you have written / want to write.


This is part of www.codehelp.co.uk Copyright © 1998-2005 Neil Williams
See the file about.html for copying conditions.