Compile Programs in Linux

google buzz

People new to linux find it often difficult to install programs from source. However, if the first hurdle is overcome, people appreciate that the fact that most programs are open-source gives you great freedom of choice. Miss a function? Maybe you find it in a nightly-build. Find a bug? Maybe you find the bug-fix already in the new source.

If you want to install a program by compiling from source, this usually begins by downloading a tarball and extracting it using the tar utility. If the file extension is tar use tar -xvvf file.tar, if it is gz use tar -xzvf file.tar.gz, for bz2 use tar -jxvf file.tar.bz2.

The GNU Compiler Collection (GCC), which includes compilers for C, C++, Fortran and other programming languages. In order to be able to compile programs you need to have GCC and some libraries installed. In ubuntu, you'll install it typing:
>> sudo apt-get install build-essential

Usually, to compile a C program to binary myprogram you type:
>> gcc -o myprogram myprogram.c
or, for C++
>> g++ -o myprogram myprogram.cpp

However, most programs that you would download need more than that. They need some configuration, detect dependencies, among other things. Usually you'll find a readme file that carries you through the steps of installation. Typical these would be configure; make; sudo make install.

What happens often is that you get back some error that you miss some library that you've never heard of. In some cases you would spend hours searching forums in order to find out in which package the library is located. A simpler way to find out you in which package your library is located is:
>> apt-file search package

If you use the rpm package manager, similarly you can use:
>> rpm -q package

No Response to "Compile Programs in Linux"

  Subscribe to replies to this post

 
This conversation is missing your voice. Your feedback is appreciated.
Post a Comment


You can use some HTML tags, such as <b>, <i>, <a>

If you see a message that says "your request could not be processed" press preview first and then post.
 
You can follow the discussion of this post by subscribing.


 
You are free to include information from this article on your own site if you provide a backlink. You can use the following markup:
<a href="http://www.myoutsourcedbrain.com/2009/06/compile-programs.html">Compile Programs in Linux</a>


 

Most Viewed

Recent Posts

Blog Archive