954,193 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Compile C code in Linux

Please help, I am leaning C on my own so you are my only Hope :o
I am using that "The C programming Language" E-book but it does not teach how to compile in linux - I was too long ago :rolleyes: when those Bell Lab guys wrote it :cry:

I am using the GNU gcc compiler, I find it hard to work with it.

Tlhokomelo
Newbie Poster
19 posts since Oct 2004
Reputation Points: 16
Solved Threads: 1
 

type gcc programName.c -o programName -Wall
and then to execute ./programName
-Wall is optional

andor
Posting Whiz in Training
276 posts since Jun 2005
Reputation Points: 251
Solved Threads: 29
 

Hey andor thank you - I've been recompiling my code in gcc so I may use the programs in Linux now, thanx again :)

If I may ask, do I use the same process to compile cpp code? Please don't say "RTFM!" It is a bit complicated - I'm new to this Linux Programming thing :)

Tlhokomelo
Newbie Poster
19 posts since Oct 2004
Reputation Points: 16
Solved Threads: 1
 

Hey andor thank you - I've been recompiling my code in gcc so I may use the programs in Linux now, thanx again :)

If I may ask, do I use the same process to compile cpp code? Please don't say "RTFM!" It is a bit complicated - I'm new to this Linux Programming thing :)


No. Istead of gcc type g++. Of course the file name is cpp instead of c.

andor
Posting Whiz in Training
276 posts since Jun 2005
Reputation Points: 251
Solved Threads: 29
 

If you're going to get serious about programming, you may want to get an Integrated Development Enviroment, or IDE. It's a program that allows you to visually manage your source code files, which is especially useful when working with large projects that may have more than one code module. It's also easier than invoking the gcc (or g++) command each time.

Maybe this list is to complex
If so, I recommend KDevelop or Anjuta.

John A
Vampirical Lurker
Team Colleague
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
 
No. Istead of gcc type g++. Of course the file name is cpp instead of c.

A rather odd thing to do for C code.

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 
A rather odd thing to do for C code.


Yup but not for c++ code

andor
Posting Whiz in Training
276 posts since Jun 2005
Reputation Points: 251
Solved Threads: 29
 
If I may ask, do I use the same process to compile cpp code?
No. Istead of gcc type g++. Of course the file name is cpp instead of c.
Yup but not for c++ code

Ya know, I swear I read that about 5 times, but I kept missing it. D'oh! :sad:

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

I think it's Automake and Autoconf that generate makefiles/configuration scripts that you can use to bundle with the program if you're planning to distribute it to ease the compilation process on other computers. Again, an IDE does all this for you.

John A
Vampirical Lurker
Team Colleague
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You