This article describes the very basics of compiling a program on Linux. It is targeted at the absolute beginner. Sometimes beginners search for programs on the web for their Linux systems, and is faced with the reality that they have to compile the program themselves, either because there exists no binary for their architecture, or the author of the program just doesn't release any binaries at all, but only sources.
The reader is expected to know how directory structures work (on any platform, not linux specific), how to move files (copy and paste files with a GUI), what zipped files are, and how to download the program/files and save them in a place they know. No programming knowledge is necesary.
It is very important to read the README file that came with the source files, as this contains additional instructions specific to that program.
Step 1 Copy the files to a "working directory"
Copy the zipped (*.tar.gz, *.gzip etc) file to a temporary directory where you will do the work. On my PC it is /home/renato/temp/
Step 2 Extract the files
You can use the GUI and with your mouse, rightclick on the file, and click on "extract here" or something similar:
or from the command line (Terminal or Console or something similar) type this command:
Step 3 Change to the program directory
From here on we will be using the command line. Open Terminal or Console or whatever command line application you have available. On my system the directory is /home/renato/temp/naev-0.5.-1/, so I will type in the command line:
Step 4 Generate a make file by running the configure script
We now need to generate a make file. Usually you will see a file called configure in the program's directory. If not and you see a file called "makefile", you can skip this step, this means the makefile is already created for you. Run the script with this command:
You will see a screen like follow: (Note the green "configure" script)
This script checks that your PC has everything needed to compile this program. If you need to install additional stuff, the configure script will tell you. If no error were encountered, you will see a file called Makefile, so you can continue to the next step.
Step 5 Compile the program
Now you compile the program using a tool called make.
After the make process is completed, you should see the executable program in your working directory. You can now run it with ./program where program is the filename of the program you just compiled.
Step 6 Move the executable somewhere else
You can now keep the executable where it is, or you can "install" it using the command make install, which will copy it to the program directory(s), in case you want to delete this temp directory.
This is the basics for compiling a program from source on a Linux (or Unix like) system. In a future article I will talk more on compiling programs you are writing yourself using the GNU toolchain (using g++, ld, as etc), without relying on an IDE to do the compilation in the background.
Want to master Microsoft Excel and take your work-from-home job prospects to the next level? Jump-start your career with our Premium A-to-Z Microsoft Excel Training Bundle from the new Gadget Hacks Shop and get lifetime access to more than 40 hours of Basic to Advanced instruction on functions, formula, tools, and more.
Other worthwhile deals to check out:
- 97% off The Ultimate 2021 White Hat Hacker Certification Bundle
- 98% off The 2021 Accounting Mastery Bootcamp Bundle
- 99% off The 2021 All-in-One Data Scientist Mega Bundle
- 59% off XSplit VCam: Lifetime Subscription (Windows)
- 98% off The 2021 Premium Learn To Code Certification Bundle
- 62% off MindMaster Mind Mapping Software: Perpetual License
- 41% off NetSpot Home Wi-Fi Analyzer: Lifetime Upgrades