Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 01-16-2009, 06:50 PM   #1
Registered: Aug 2005
Location: California
Distribution: Knoppix
Posts: 32

Rep: Reputation: 15
Makefiles; "builds," and linking, for the newb

Yes I understand the difference between source code and an executable. I understand that a compiler converts the former to the latter.

Except, that's all I understand; and obviously I need to understand more if I'm going to be a member of this here open-source community.

For instance, I want to have Ruby (Matz's adored scripting language) on my Linux box. This seems to mean that I must "build" Ruby. From the Ruby website there's a whole pile of stuff to download. I was hoping there would be one huge file full o' source code; and that I could feed the file to my gcc compiler and voilą; I'd be in business.

Also, in trying to get Ubuntu to dig my laptop's IR port, at some point I have to do a "make file" or "make install."

So what's the next step in getting familiar with all this stuff? We've done the "Hello World!" program and compiled it; we've got compiling down pat. But now there's "make?"

And what the heck are these object files? The compiler turns your code into object files; then the object files have to be "linked" to something. And object files contain machine code AS WELL as text? Isn't the text going to screw up the machine yes MACHINE that's looking in that there file 'cause it needs MACHINE code?

Object file

what's it all mean, baby...
Old 01-16-2009, 07:29 PM   #2
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
For instance, I want to have Ruby (Matz's adored scripting language) on my Linux box. This seems to mean that I must "build" Ruby.

I don't think that there'd be many distros (you're doing LFS?)
that will require you to compile ruby from source rather than
just installing it via a distro-specific package ...

We've done the "Hello World!" program and compiled it; we've got compiling down pat. But now there's "make?"
You've just taken the next step; Makefiles help you with compilation
of largish/more complex projects - simple as that. Unless you want
to write something yourself or run into problems with other peoples
source-packages you don't really *need* to know make all that well.
Mind you, some use it in very creative ways, e.g. for time-driven
generation of LaTeX documentation :}

Basically what make does is to take a file that describes how the
files in a project hang together, and when it finds a discrepancy
in the time-stamps on those files it will regenerate the required
target files based on the rules defined within the Makefile.

Old 01-17-2009, 12:51 AM   #3
LQ Guru
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,465

Rep: Reputation: Disabled
simple compiling

Hi WK,
As Tinkster said ruby generally comes pre-compiled (i.e. as binaries) for most linux distros so you don't have to compile it. In general, compiling is quite easy (even I can do it). So here's a quick howto.
1. Download the source code. This typically comes as a "tarball" (a compressed file with the extension -----.tar.gz
2. Open a terminal and navigate to the folder where you downloaded the tarball.
3. At the terminal prompt type:
tar zxvf [name of tarball]
You will see a large number (usually) of files being uncompressed to a new folder where all the source code is found.
4. cd to the newly created folder (its name appears at the beginning of every file extracted from the tarball).
5. Now that you're in the new folder, type
at the command prompt. You should see a file called "configure". (If there is no "configure" file go to step 7.)
6. Now type
7. Assuming you get no errors, now type
8. Now become root (type "su" and then the root password or type "sudo" and you will be prompted for your own password if sudo has been set up) and type
make install
That's it. If there are no errors your executables are usually installed in /usr/local/bin
Occasionally the tarball ends in bz2 instead of gz. Just change the command given in step 3 to
tar jxvf [name of tarball]
Everything else is the same.

This is not the only method for compiling but just the one that you will come across most frequently.
Old 01-17-2009, 03:11 AM   #4
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
I'd like to add an extra step 5a: check for and read any READ, README, INSTALL and similar files. These tell you about any extra steps/issues you may need to take into consideration before/during configure.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: U. of Hawaii, M?noa, builds "new again" computer lab with Linux LXer Syndicated Linux News 0 11-18-2008 04:40 AM
LXer: EFF: claim that consent needed for linking is "preposterous" LXer Syndicated Linux News 0 09-25-2008 01:51 PM
add "-g" gcc compile option to makefiles powah Programming 1 08-11-2007 02:28 AM
gnu arm issue in linking "__inline" methods RPDP Programming 10 09-30-2006 08:11 AM
Is it possible to add a "DESTDIR" variable in makefiles that don't have it ? nasty_daemon Programming 2 11-25-2005 02:24 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:25 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration