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.

http://www.gnu.org/software/libc/libc.html
http://www.gnu.org/software/libc/manual/html_node/Introduction.html.

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.

http://www.fsf.org/licenses/gpl-faq.html

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:

http://isbn.mania.or.id/html/isbn.php?isbn=0789722151
http://www.isbn.org.uk/html/isbn.php?isbn=0672315971.

and lots of websites.

http://linuxadvisor.net/doc/13368
http://www.start-linux.com/articles/article_75.php
http://www.icanprogram.com/linuxProgramming.html

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:

http://code.neil.williamsleesmill.me.uk/doxygen/

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:

http://code.neil.williamsleesmill.me.uk/

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

http://code.neil.williamsleesmill.me.uk/palm.html#AEN296

Substitute any large program for GnuCash in that example.

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

http://www.cs.cf.ac.uk/Dave/C/node35.html

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.

http://sourceforge.net/
http://www.freshmeat.net/



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