LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 01-16-2009, 05:50 PM   #1
WindsorKnot
Member
 
Registered: Aug 2005
Location: Minneapolis
Distribution: Ubuntu 14.04
Posts: 36

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?

Make
Build
Link
Object file

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

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
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 ...


Quote:
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.


Cheers,
Tink
 
Old 01-16-2009, 11:51 PM   #3
jdkaye
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:
Code:
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
Code:
ls
at the command prompt. You should see a file called "configure". (If there is no "configure" file go to step 7.)
6. Now type
Code:
./configure
7. Assuming you get no errors, now type
Code:
make
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
Code:
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
Code:
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.
Cheers,
JDK
 
Old 01-17-2009, 02:11 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,344

Rep: Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746
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.
 
  


Reply


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 03:40 AM
LXer: EFF: claim that consent needed for linking is "preposterous" LXer Syndicated Linux News 0 09-25-2008 12:51 PM
add "-g" gcc compile option to makefiles powah Programming 1 08-11-2007 01:28 AM
gnu arm issue in linking "__inline" methods RPDP Programming 10 09-30-2006 07:11 AM
Is it possible to add a "DESTDIR" variable in makefiles that don't have it ? nasty_daemon Programming 2 11-25-2005 01:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:11 AM.

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