work
How to Compile Software From Source Code
Posted by Gina Trapani at 12:30 AM on July 17, 2008
When you run across good-looking open source software which isn't available as an executable, installable file, it's time to get down and dirty with the source code at the command line. Tech tutorial site Webmonkey describes how to compile software from source. The process involves three main steps—the basic commands in order are configure, make, and make install. You can get tripped up if your system doesn't have a compiler, or the software has dependencies that aren't available, but those issues are easily resolved—and there's no better feeling when you're starting to get comfortable at the command line than the first time you successfully compile software from source. This howto's a great place to start.
Tags: command line | source code | work

Comments (AU Comments · US Comments)
There are currently no AU comments for this post.
superbryant
Posted 1:09 AM 17/7/08
nice it took me forever to learn how to do this on my own in linux, which lead to man a lot of screwed of directories. But once you learn it once it is the easiest thing in the world
superbryant
Luigi193
Posted 1:22 AM 17/7/08
"and there's no better feeling when you're starting to get comfortable at the command line than the first time you successfully compile software from source"
Totally... when I complied a program for the first time, I thought it was the coolest thing in the world!!!
Luigi193
wakeboarderal05
Posted 2:15 AM 17/7/08
@zhinker: Most of the programs that you would need to compile from source are going to be linux/unix programs, and therefore would not compile in Windows. It might be possible to compile some using Cygwin in Windows, but most of the time there will be binary executable if there is a Windows port of the program.
wakeboarderal05
zhinker
Posted 1:59 AM 17/7/08
nice link. My only complaint is that all the command line instructions are written for Linux users and aren't really applicable to Windows.
Does anyone know what the equivalent commands would be?
zhinker
aphexbr
Posted 1:54 AM 17/7/08
I use Linux and while it's not as necessary as it used to be, if you have to have an unpackaged program, compiling from source is getting easier all the time...
Check the install file for dependencies, use your distro's package manager to make sure you have them, configure, make, install. It was a nightmare when I first started out, not it's almost a no brainer. Not just because I'm more competent with Linux now, but because things rarely fail for me on the first attempt.
aphexbr
andrewheiss
Posted 2:29 AM 17/7/08
@zhinker: If you find any source files that can be used by Windows, you'll need a Windows C compiler to run nmake and other programs. You'll have to download the free Visual C++ Express (unless you have the full one in Visual Studio already) and use the special C++ console/terminal (unless you add the compiling programs to your path). I tried compiling some Perl modules a while back in Vista and it worked.
andrewheiss
desigi
Posted 2:21 AM 17/7/08
@superbryant: Same here. And to this day I still don't think I was doing it properly. That was the one thing that kept me going back to Windows... that and the random sound problems I was experiencing with different distros.
desigi
satan gave me a taco
Posted 3:57 AM 17/7/08
Man, I don't know what my problem is but every time I try to compile something from the source on my Mac, it never works. I've tried VLC, Firefox, and some other utility that I can't think of the name of right now. I'll read this when I get home and see if it helps.
satan gave me a taco
jarmod
Posted 3:36 AM 17/7/08
I think you should generally steer clear of any software that requires you to download and compile source code.
jarmod
dphelan
Posted 4:45 AM 17/7/08
@satan gave me a taco: Make sure you have the Developer Tools installed. They're on your OS X DVD, but don't install by default.
dphelan
sphetr2
Posted 5:04 AM 17/7/08
@jarmod: please shut up
sphetr2
Deprong Mori
Posted 6:53 AM 17/7/08
Do not install the Developer Tools from your OS X DVD. They're old.
Register at developer.apple.com and download the most recent version of Xcode software from the ADC site.
Read the source code bundle's documentation very carefully -- paying special attention to prerequisites. Good luck.
Deprong Mori
ianturton
Posted 5:12 AM 17/7/08
@zhinker: if you install cygwin (including the developers tools) most of the same instructions apply. But to be honest it's still hard work and you'll probably be better off finding a precompiled binary of windows.
ianturton
q335r49
Posted 12:44 PM 17/7/08
Wow sweet... I've been trying to get rogue to run on myPowerPc (Macbook G3) Linux machine for days (my real laptop's getting repaired).... I had no idea it was configure... make... install.
Amulet of Yendor, here I come!
q335r49
nsr81
Posted 10:42 PM 17/7/08
That's funny, I just put up a new CentOS server, named "nyx" :D
@Luigi193: The ultimate command line comfort test: Compile a kernel lol
nsr81
ahoier
Posted 2:36 AM 18/7/08
Sometimes compiling from source has it's advantages ;)
For example, isn't it "the Gimp" that doesn't offer executables from their site, you have to "go elsewhere" to find the executables...? For some reason I don't know.
But I ran into a program that had a "nag screen" of sorts, but since the author released the source code (via sourceforge) - one with craftiness, could peruse the code, find what needed to be removed, remove it, and re-compile it on their own without the nag.
ahoier
piyo
Posted 12:49 PM 19/7/08
The tips from TFA are for Unix-alike systems, such as Linux-based OSs.
For the "./configure && make && make install" sequence, you can thank the GNU Autotools suite which includes GNU Autoconf. This is documented on Wikipedia as the GNU build system.
Building from source is fun and convenient, but you have to read and follow directions (if there is any documentation to begin with, huh). For further tools worthy of study that help with the installation of source-compiled apps, I recommend looking at roastbeef (downloads from source control and compiles for you, on Ubuntu) and GNU Stow (Unix-alike-platform app installer to /usr/local/bin or other places).
And yes, Windows users don't have it this easy (because of the install from binary culture), but that's a topic for another post. For an example of compiling a non-trivial open-source Windows app with freeware tools, here are instructions for Lifehacker's hero AutoHotKey, complete with dialog boxes, haha.
piyo