Question:
how i can compile and run a c program in linux rat hat?
babu
2006-12-27 22:16:46 UTC
how i can compile and run a c program in linux rat hat?
Seven answers:
greg m
2006-12-27 22:23:16 UTC
search for information on compiling a kernel, Redhat and Fedora have dependencies that must be met before compiling and installing source code. GCC is at the core of what you need.

Good luck
techieguy
2006-12-27 22:23:11 UTC
It's "Red Hat" Linux. If it has been installed properly, there would be a C compiler called "gcc". Just type:



gcc -o myprog myprog.c



at the prompt, where "myprog.c" is your C program file. The compiler will create an executable called "myprog" in the current directory. You can then run it directly by typing the following at the prompt:



myprog
csanon
2006-12-27 22:21:41 UTC
The C compiler on linux is gcc. "man gcc" at a terminal should get you important switches. And google will help you with the rest.



If you don't want to play around with makefiles on larger projects, use an IDE like kdevelop.
victor
2006-12-27 22:25:39 UTC
You can compile using

$ cc



For example

$ cc sample.c



It will create a object file called a.out. To run the program

$ ./a.out



you can also create your own object file instead default a.out using

$sample.c -o sample.c



To run the program just type at the command prompt

$sample.c



You can also use gcc

$gcc

$ gcc sample.c
Satya
2006-12-27 22:32:34 UTC
Suppose name of the C file is fact.c,

$ gcc fact.c

Generates a.out in the same directory.. To run do following:

$./a.out



When you compile you can also give executable name of your choice as,

$gcc -ofact fact.c

The above command generate executable with name "fact"
granpagts1
2006-12-27 22:21:23 UTC
look at "man make" on your linux box from a console session. I forget how to set the linkage (convert compliled program to executable code).
danceingame
2006-12-29 08:25:41 UTC
Learn linux using mind map.

http://mind-map-you.blogspot.com


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...