New to C Programming in UNIX environment

Hi all,

I know the basics of C programming, but I dont know a single thing about how to write, compile and run C code in UNIX, also where liberaris are stored, how .headers files are being managed in unix, how to debug c code and what are the available GNU tools for c programming in linux env, and what are the advantages of c programming in unix env.

Can any body give me the start. Thnx in advance.

Cheers,
Patras

Lets see, you can write code in unix with any of the myriad of text editors available - try to familiarise yourself with either the vi or the emacs editors. For compiling code, you can use the GCC (have to install it seperately - though it will usually be available on Linux by default). Many systems come with their native C compilers, like Sun Studio on Sun or HP's HP C compiler.

On almost all systems, the libraries are available under /usr/lib, while includes are under /usr/include. Both libraries and include files specific to a certain products may be installed elsewhere during product installation as well.

As for debugging, you can use GDB which is part of the GCC. For more info on GCC, go here.

Thanks for your reply. So it means path for header and liberary files is setup in system kernel at the time of installation? Because I never configured any path and compiled my first program with cc today and it went thru.

I dont have gcc installed, is there any major difference btw cc and gcc? Or initially I can continue with cc only. Any documentation is available for cc? I tried to understand the man page but not satisfactory, any good debugger link also pls.

thanks in advance.

cheers,
Patras

What OS are you working on? That may tell you what native C compiler you've used. Also, check the output for 'ls -l `which cc`'. (Note the backquotes around 'which'). You may find that cc is actually a link to gcc (quite common). As for the documentation, is it for learning C or learning how to use cc/gcc? For C and debugging links, check the Unix Tutorials/Programming Tutorials/Shell Scripting Tutorials page.

In fact, I think that should answer almost all your questions. And one more piece of advice... check the FAQs page. You will get tutorials, recommended pages, ready-made scripts and more.

Thanks for your reply. I'm at SCO Unixware, here is the output of which command:

$ ls -l `/usr/ucb/which cc`
lrwxrwxrwx    1 root     sys              15 Apr 16  2002 /usr/bin/cc -> /usr/ccs/bin/cc

I think its cc only not a link to gcc, I'll go thru FAQ's also.

Thanks for all your help.

Cheers,
Patras

close, not in the kernel, but in gcc itself.

Which is as it should be.

[quote]
I dont have gcc installed, is there any major difference btw cc and gcc?

cc and gcc ought to understand some of the same options, but not all of them. The -o, -I, -l, and -L flags ought to work the same.

On my solaris 9, its:
lrwxrwxrwx 1 root other 14 Feb 7 12:03 /opt/SUNWspro/bin/CC -> ../prod/bin/CC