Q. I've downloaded tar ball software but I don't know how to compile the same? Can you provide the instructions for compiling a program?
A. Many new users find it difficult to compiling programs in Linux. Usually following steps are involved:
a] Download tar ball using wget
b] Untar tar ball using tar command
c] Compile program using make or configure command
d] Install software
Task: compiling program
Step # 1: Download program tar ball:
$ wget http://url-com/prog.tar.gz
Step # 2: Untar tar ball :
$ tar -zxvf prog.tar.gz
$ cd prog
Step # 3: Untar tar ball:
Install program (must be run as the root, login using su or use sudo):
$ sudo make install
$ su -
$ make install
Q. I am new to Linux but not to c programming. At university we are using Turbo C compiler under DOS/Windows XP to write and compile C programs. Under Linux I’ve small program called test.c. How do I compile and see the output of C program in Linux? Note I’m using Fedora Core Linux.
A. Under Linux you need to gcc (GNU project C and C++ compiler) command to compile a program. When you compile a program it generates an executable file called a.out.
gcc -o output-file program.c
Task: Compile program
To compile type the command:
$ gcc test.c
Task: Execute program to see output
Above command will create a file called a.out. To see output of test.c program type:
Task: Compile to specific executable file
You can specify an execuable file name while compiling program itself:
$ gcc -o test test.c
Now execute test (see output of test.c)
here is my GNU C compiler? Where does the GNU C (gcc) compiler reside in the RHEL / Fedora / Debian / Ubuntu / CentOS Linux installation? How do I install GNU c/c++ compiler in Linux operating systems? [click to continue…]
How do I compile C program and create an executable file under Linux or UNIX operating systems?
[click to continue…]