How to learn to compile from source with dependencies and libraries needed?
Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to learn to compile from source with dependencies and libraries needed?
What is the best way to learn how to compile programs from source with dependencies and libraries? Yes, I know the syntax for running configure/make/make install etc. for basic programs but I'm really trying to up my ability and knowledge. For example, I just recently installed Gimp 2.8 from source on Ubuntu 12.04 following a really great tutorial on how to do so from a popular blog - it worked great and Gimp seems to run without issue. During the course of the installation the tutorial had me install several libraries among other things. It's fuzzy to me how this blogger was able to figure out all of the libraries dependencies that was needed to get Gimp to run....how did he detect those? I want to know how to do this.
I really want to learn how to take control of my machine. If a new program(Gimp or otherwise) comes out I don't want to wait for it to show up in the "software center" or install it via a ppa. Is there a really good tutorial or method on this? I'd like to get to the point to where I install everything from source if possible including the latest version of Gimp from scratch.
(I'm just using Gimp as an example...I'm not really looking for instructions on how to install it in particular)
I don't think there's a general tutorial that says more than you have just said.
Imo it's up to the developer to include documentation (or some hints at least ... for developers that don't like documentation). For the GIMP, for example, http://www.gimp.org/source/ says
Quote:
All requirements below must be met to be able compiling GIMP from source. This list might change depending on the releases being worked on during development of GIMP. Look at the files INSTALL and README in the tarballs for details.
and then lists a bunch of optional packages.
Some packages will need to be installed in a certain order, but most not: you only need them installed before you run the app. Again, the README or INSTALL or other package files should specify this ... or at least errors during make should give you a clue. Other dependencies would spit out errors at runtime.
Ok, as obvious as that seems I didn't even think to look there in the README and INSTALL documentation! I think what I'll do is set up a machine identical to current one in Virtualbox and test install apps there before I do it on my main version just in case anything breaks.
For ones that are missing documentation, usually the configure or make commands will error out with a suggestion of what you need to install.
Isn't that risky though? Couldn't just blindly running make commands and having a program partially install break my system? I've always been hesitant to do this because I thought that was the case.....please correct me if I'm wrong.
The installation procedure for almost any piece of source code usually follows the same three steps:
./configure <args>
make
make install
the configure script will check for MOST dependencies, and error out if you're missing any. Nothing is altered in your system in any way from the configure script, it just prepares the files in the local directory for make.
The make command will build the software IN PLACE, erroring out if anything fails. Again, nothing is altered in your system from this make call, everything it modifies is in the local directory and that's it.
The make install command is used to copy the files created by make to the necessary places in the system. This is the only part of the process in which your system (outside of the local directory) will be altered, and this step will almost never fail assuming "make" went through fine.
You can run ./configure and make at any time you want. They can go through fine, error out, it doesn't matter, nothing outside of the current directory is altered by either of these steps. This is why you can run these commands as your regular user, you don't need to be root. You only need to be root for the make install, which is only run AFTER make was successful, which means your dependencies have been resolved.
Last edited by suicidaleggroll; 10-04-2012 at 12:04 PM.
The installation procedure for almost any piece of source code usually follows the same three steps:
./configure <args>
make
make install
the configure script will check for MOST dependencies, and error out if you're missing any. Nothing is altered in your system in any way from the configure script, it just prepares the files in the local directory for make.
The make command will build the software IN PLACE, erroring out if anything fails. Again, nothing is altered in your system from this make call, everything it modifies is in the local directory and that's it.
The make install command is used to copy the files created by make to the necessary places in the system. This is the only part of the process in which your system (outside of the local directory) will be altered, and this step will almost never fail assuming "make" went through fine.
You can run ./configure and make at any time you want. They can go through fine, error out, it doesn't matter, nothing outside of the current directory is altered by either of these steps. This is why you can run these commands as your regular user, you don't need to be root. You only need to be root for the make install, which is only run AFTER make was successful, which means your dependencies have been resolved.
Thank you so much for that clarification. There's so many tutorials out there but none of them will actually tell you the consequences of what you're doing - especially if you run into problems. Many times.....I've followed a tutorial(not installing apps, but with other things) only to be led astray and ultimately ended up with a broken system.
1. If "make" fails because something is missing, run "make clean". That will remove all the object files that have been created so far, so that next time it doesn't keep saying that it's done this bit already and should it do it again.
2. Keep the package. Most make-files have an uninstall section, so "make uninstall" will cleanly remove the program for you, saving you from tracing the various bits. Even if it doesn't have this, the install section will at least show you where it put everything.
You already know the fundamentals of compiling from source, but if you really want to know more about compiling from source and resolving those unexpected issues and managing your system try slackware. You will learn a lot about compiling from source with slackware.
There are slackbuild scripts found at http://slackbuilds.org/ for many packages and their dependencies. After more experience you can create your own slackbuild scripts for yourself or share with the slackware community.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.