How To Build A Typical Linux Project

How To Build A Typical Linux Project
FacebookXFlipboardEmailShare

If you are using Linux, it makes a lot of sense to download and use various Free and Open Source software. While frequently you will be able to download and install various RPMs, there are a lot of projects that do not provide any user friendly installers. Some projects even do not have the explicit releases. From the other side, building from the source may produce an application that is much better optimized to your processor and operating system. Surely, you must also be able to build a Free / Open Source project if you want to master it enough to join as developer later.

If the project has no explicit releases, you may need to pull the source code directly from its CVS or SVN repository. The websites of most such projects will have the corresponding command line which you only need to copy-paste to your system, for instance cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/sources/classpath co classpath. The similar command usually downloads a large number of project files in a current folder.

Look into the files README and INSTALL that should be at the top folder in the downloaded project. They may contain valuable information that will save you a lot of time.

Some projects provide the build script as a shell script (usually named build.sh). This is not very frequent, but happens for very old projects and also for new projects that try to provide a “user friendly” build procedure. If you find such file, try to use it first (the installation may be placed in a separate script that is usually named install.sh). If you find these scripts, just run them. Otherwise, proceed to the following steps.

Search for the file called configure which also must be present in a project top folder. It is usually a .sh script that will tune the project build system to your machine. If you find it, type ./configure or sh configure to run this script. ./configure usually has a lot of options that may help if the “default” run fails with error messages. Run the script with the key –help to see the options. If there is no configure script, it may be an old – style project which only uses makefiles, so you can proceed directly to the next step.

Search for the file called makefile which may be initially present or appear after you run configure. If you find it, type the command make. It should find the makefile in the current directory and build the project for you.

If there is no configure nor makefile in the project tree, it may be an ant – powered project with the build.xml file instead. In this case, type ant in the project root folder. While make is more popular for C and C++ projects, ant is popular for java projects.

If ant doesn’t work either, or the project is C or C++, try running ./autogen.sh to create the configure and makefile files. This uses autoconf, automake and libtool to create these files.

After you succeeded to compile the makefile – based project, try make install to place the project files into appropriate locations (to install the project). The default locations like /usr/lib or /usr/bin are usually only root-writeable, so this step usually needs administrator rights.

After the installation succeeds, try to type the short project name. This usually invokes the newly compiled and installed program which is now ready to use.

Note

FacebookXFlipboardEmailShare
Exit mobile version