compiling from source, help for beginnners?

How can I get started compiling applications from source?

Page 1 of 1

5 Replies - 1368 Views - Last Post: 25 June 2009 - 08:45 PM

#1 crazyjugglerdrummer  Icon User is offline

  • GAME OVER. NERD WINS.
  • member icon

Reputation: 119
  • View blog
  • Posts: 690
  • Joined: 07-January 09

compiling from source, help for beginnners?

Posted 19 June 2009 - 01:25 PM

I've known for a while that compiling yours applications from source was a huge step on the "ladder or nerdom/nerdiness/geekification." At first I wondered, why would you download the source code when you can just download the actual application already compiled? Then I read some stuff about how compiling form source with your own compiler can make an app run much faster.
I know CFS is a big linux thing, but I'd love to know how it works on mac and particularly windows.



So my question is: What does compiling from source involve, and how can I get started doing it?




What tools do you need? (just compilers? Visual studio? Xcode? Probably need professional version of VS, ) Do you just paste the source code and hit build? (probably not.....)


Thanks guys!!!!! :D

Is This A Good Question/Topic? 0
  • +

Replies To: compiling from source, help for beginnners?

#2 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5832
  • View blog
  • Posts: 12,685
  • Joined: 16-October 07

Re: compiling from source, help for beginnners?

Posted 19 June 2009 - 02:42 PM

I depends on the source and the system. It's far more common in Linux land than Windows.

A vast number of projects in Linux follow the "GNU build system" or use the Autotools suit, for distribution. You don't have to know what that means, all you have to do know is this. If you download source code for a Linux program and unarchive it into a directory, the process of installing it will often be just three magic commands.

./configure
make
sudo make install



If all goes well, you have software. A failure likely means that your system doesn't have a needed dependency. The dependency will be a developer library, or two, or three...

The following, like the above, is Ubuntu centric, but others are similar.

To compile from source, you need at least one thing:
sudo apt-get install build-essential



Recently I wrote a screen saver thingy. For example, to install it from source, you'll need to install two common dependencies.
sudo apt-get install libx11-dev libxpm-dev



If it's gnome, you might have more. If it's security, more, etc, etc. Installing from source generally means you have a ton of libraries on your machine. It also means you get to play with software at it's newest version, for good or ill.
Was This Post Helpful? 0
  • +
  • -

#3 Raynes  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 611
  • View blog
  • Posts: 2,815
  • Joined: 05-January 09

Re: compiling from source, help for beginnners?

Posted 19 June 2009 - 05:40 PM

Compiling from source can make applications run faster, because said applications are being built on your hardware, on your computer. Usually, the main reason to compile from source is if an application isn't available for your particular operating system distribution, or operating system period. For instance, GHC 6.10.3 isn't available on the Ubuntu Hardy repositories, so a few weeks ago I simply built it from source. No applications that I know of, have an easy way to build source code on Windows. On Linux, most applications offer the GNU build system (make).
Was This Post Helpful? 0
  • +
  • -

#4 code_m  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 24
  • View blog
  • Posts: 202
  • Joined: 21-April 09

Re: compiling from source, help for beginnners?

Posted 22 June 2009 - 07:17 PM

I haven't done it, but I would assume the best way to install from source on windows is to use cygwin.. and OS X is a Unix based system, so you can ./configure the same way you could on Linux.

I'd suppose the hard way (and un-free way) of doing is to get VS and place all the (needed) files into a project and then compile from the "main.c" or "main.cpp" file, as most source projects you find are C and C++. The problem here is that you might need to edit some of the #ifdef because this is normally set off by configure.

I'd try googling "configure on windows" or "configure +windows"
Was This Post Helpful? 0
  • +
  • -

#5 Tom9729  Icon User is offline

  • Segmentation fault
  • member icon

Reputation: 180
  • View blog
  • Posts: 2,641
  • Joined: 30-December 07

Re: compiling from source, help for beginnners?

Posted 24 June 2009 - 07:28 PM

I'd recommend MinGW over Cygwin if you're going to try compiling programs on Windows. Generally it is ./configure && make && make install as Baavgai said, but sometimes there are exceptions so always look for a readme file (generally named README or INSTALL). For example, sometimes if you check a project out of a VCS like subversion you'll have to run a script called autogen.sh which includes the ./configure step.

If you're compiling software that doesn't use autotools, RTFM. :)

I've seen some programs/libraries that generally use autotools, but have special build scripts for Windows that use MSVC (libxml2 uses build scripts written in jscript last time I checked).

Compiling from source will PROBABLY NOT make your programs magically run faster. Sometimes you can disable features and enable some processor specific optimizations, but most of the time the "performance improvements" you get will be the kind that really only show up in benchmarks (ie. you really won't notice them).

Edit: A good rule of thumb, don't compile from source unless you need to or are very bored.

This post has been edited by Tom9729: 24 June 2009 - 07:30 PM

Was This Post Helpful? 1
  • +
  • -

#6 code_m  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 24
  • View blog
  • Posts: 202
  • Joined: 21-April 09

Re: compiling from source, help for beginnners?

Posted 25 June 2009 - 08:45 PM

Quote

A good rule of thumb, don't compile from source unless you need to or are very bored.


A great way to look at it !

Which btw, compiling from source use to have HUGE performance gains, but mostly in the server market where thousands of programs are running at once. Today it's less need because of processor technology has improved significantly.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1