Beginner’s Guide to Compiling C and C++ Software in Linux

June 17, 2008 at 12:00 am 1 comment

For people that are new to the GNU/Linux operating system, compiling software can be confusing. However, somewhat simple C and C++ packages can often be compiled with little to no hassle.

Before you begin, open up your package manager to verify that you have the “gcc” compiler installed. (This may include Synaptic and KPackage) Many GNU/Linux distributions that make claims towards user friendliness often do not include this in the default install. If you are on Ubuntu, you want the build-essential package.

Open up your terminal at this point. On the menu, this is often found in the System category. If you are unable to find this, you can run the program xterm.

Now you need to extract the source code. From the command line, use tar xfjv yourfilenamehere for .tar.bz2 files and tar xfvz yourfilenamehere for .tar.gz files. If you have source code in a zip file, use unzip yourfilenamehere.

Finally, we are going to change to the directory that was generated. Type in cd nameofdircetory to get there. If you are unsure as to the exact name, simply use the command: ls. This will list all of the files and directories in your home directory.

Now you are ready to actually compile the program. Use the following commands one after another. If they do not work, you need to consult the INSTALL file (more INSTALL) for instructions.

./configure
sudo make
sudo make install

If you encounter any errors after running ./configure, you probably need to install libraries. For compiling softwrare, you need to find the library that has -dev or -devel at the end of the name in your package manager, or it will not be usable to the compiler. For instance, if libglade were missing, you would need to install libglade-dev or libglade-devel.

Good job! You should now have a program compiled. There can be problems, especially with larger programs. If all searches and these tips fail, you may have to look for furthur documentation.

Advertisements

Entry filed under: Tutorials. Tags: , , , .

Set up AdblocK in Konqueror 3.5

1 Comment Add your own

  • 1. ameo  |  June 24, 2008 at 8:03 am

    i’m not used to linux as much as windows .
    but can’t C++ software be packed as RPM ? or .deb or any other autoinstall file ?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Categories

Recent Posts


%d bloggers like this: