LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   What does "make install" actually do? (https://www.linuxquestions.org/questions/linux-software-2/what-does-make-install-actually-do-712942/)

crabpot8 03-19-2009 04:37 PM

What does "make install" actually do?
 
Hey all,

For some classes I have to use the ACE_OS library. I have really had no issues, but I have always wondered why you have to do "make install"

what does this command do? Does it have something to do with shared libraries?

I know on the school computers sometimes I cannot run programs that I have compiled with and ACE_OS dependency, but if I type
$setenv LD_LIBRARY_PATH /path/to/ace_os5.6.5.so

then it will run fine (I obviously dont have root access on these machines, so I could never figure out how to make this "cannot find shared object" error go away permanently

Thanks,
crab

TB0ne 03-19-2009 04:45 PM

Quote:

Originally Posted by crabpot8 (Post 3481261)
Hey all,

For some classes I have to use the ACE_OS library. I have really had no issues, but I have always wondered why you have to do "make install"

what does this command do? Does it have something to do with shared libraries?

I know on the school computers sometimes I cannot run programs that I have compiled with and ACE_OS dependency, but if I type
$setenv LD_LIBRARY_PATH /path/to/ace_os5.6.5.so

then it will run fine (I obviously dont have root access on these machines, so I could never figure out how to make this "cannot find shared object" error go away permanently

Thanks,
crab

It runs through the Makefile, and performs the install, based on the instructions in it. Puts it into locations, does whatever. When you type in "make", it builds the object(s).

The Makefile is essentially a list of instructions, saying how programs should be compiled/linked/installed/whatever. That's a very simplified way of stating it, but that's what "make install" does.

i92guboj 03-19-2009 04:53 PM

Quote:

Originally Posted by crabpot8 (Post 3481261)
Hey all,

For some classes I have to use the ACE_OS library. I have really had no issues, but I have always wondered why you have to do "make install"

What does "make install" do entirely depends on the concrete case we are talking about. "make" is a tool that -unless otherwise instructed via command line options- looks into the current directory for a makefile, and builds the target you instructed it to build. In this case, the target is "install". Such target is usually scripted in a fashion that it will install a number of files after the program is compiled. Each file to the right place (i.e. binaries in /bin or /usr/bin, docs in /usr/share/doc..... ), but it will also set permissions and ownerships and maybe do some other tasks.

So, in short, to compile a program you usually do "make", and to install it after compiling you do "make install". Usually you do need root permissions if you want to install to /

Quote:

what does this command do? Does it have something to do with shared libraries?
It usually installs the stuff in your system, however, this entirely depends on the one who scripted the makefile. It wouldn't make much sense to use the "install" target to launch a pacman clone, but it's certainly possible to do so.

But, you can safely assume that "make install" will install the program or whatever you just built in your system.

Quote:

I know on the school computers sometimes I cannot run programs that I have compiled with and ACE_OS dependency, but if I type
$setenv LD_LIBRARY_PATH /path/to/ace_os5.6.5.so

then it will run fine (I obviously dont have root access on these machines, so I could never figure out how to make this "cannot find shared object" error go away permanently
LD_LIBRARY_PATH is an environment variable that contains paths where to search for dynamic link libraries that your programs will need to run. If you could install this library on the system then you wouldn't need to worry (hence, it might be a good idea to ask the admin if it's possible to do so). If you can't get the library installed in the system, then you need to put it on some other directory, and then add that directory to LD_LIBRARY_PATH as you are doing right now.

You can automate this process. But this entirely depends on how do you work. If you login in command line mode and you use bash as your shell, then you just need to add this into your ~/.bash_profile file:

Code:

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/path/to/whatever/"
If you intend to use an xterm instead, then this would go into ~/.bashrc. You can just put it in both as well. I also recommend reading the "INVOCATION" section in the bash man page (assuming that you use bash, if not, then read the man page for your shell, whatever that is).

It just depends on how do you login and your shell of choice.

colucix 03-19-2009 04:55 PM

The make install step of the installation process, just copies the compiled programs, the man pages, the shared objects and so on... to their specific locations. External programs compiled from source are usually installed in /usr/local by default but this is not a general rule. It depends on the developer's choice. Obviously, if you don't have root privileges, you cannot install a software into directories owned by root.

Anyway, you can specify a custom installation directory in the configure step, usually:
Code:

./configure --prefix=/home/crab
if you choose a directory owned by you as a user, you can actually install a program (that is you can perform the make install step without being root). Take in mind that the installation step may create directories if they don't exist: if you choose your home as installation directory, maybe you will end up with newly created directories like /home/crab/bin, /home/crab/man, /home/crab/lib.

To avoid this you can install the program into the source directory itself and then create link to the executables in the $HOME/bin directory (on most distribution it is already in the PATH) and create/modify the environment variables needed by the program to run.

LD_LIBRARY_PATH is one of these variables. It contains the path (multiple paths separated by colon) of the shared objects (libraries) that are not in standard locations like /lib, /usr/lib, /usr/lib64 and so on.

If you want to make the modification permanent, just add
Code:

setenv LD_LIBRARY_PATH /path/to/ace_os5.6.5.so
to the file $HOME/.cshrc. This file is sourced by the C-shell every time you start a new session, so that the needed environment will be always available to the user.

JaksoDebr 03-19-2009 07:38 PM

'make install' does only what is defined for it in the Makefile. If the Makefile doesn't have a section for it, then it does nothing.

Commonly 'make install' will be run as root and be responsible to copy the relevant executables and configuration files in proper places on the system, so that any user can use it. When installing an application into /usr/bin (a location in the $PATH of all users), then the application can be launched without having to specify the full pathname.

If you omit the 'make install' step, then you need to launch the application either by going to the specific directory (and even running it like './appname') or by giving the full pathname.

Linux Archive

crabpot8 03-20-2009 11:36 AM

Wow, thanks so much to all. I guess this is a case of the simple explanation was not the one I ever thought of!

It makes sense now, thanks to everyone for the thorough responses!

Crab

sundialsvcs 03-20-2009 12:06 PM

Somewhere nearby, you'll find a file named: Makefile. Open it up, and have a look inside. (But don't touch anything...)

You'll find the word install in there somewhere... it's what we call a make target. You'll also probably find other make-targets, like all and clean.

In any case, the essential information that you find in a Makefile is: "what depends on what, and if you determine that something needs to be rebuilt, how do you do it?"

Thus, for example, when you say make install, the "make" utility is going to find that target, and work backwards to see what prerequisites there are, and to determine whether those prerequisite steps have already been done. For instance, if the program hasn't been compiled yet, that will happen first, then the stuff will be "installed." (And the Makefile will specify exactly how to do that.)

make is one of those utilities for which the concept is intuitively simple, and the implementation can be quite complex indeed. (And we haven't even touched on configure!) In any case, we can usually stick to the "intuitively simple," namely, "it just works." You can just tell it what to make, and ... sit back and watch the pretty blinking lights.

crabpot8 03-21-2009 03:10 PM

Quote:

Originally Posted by sundialsvcs (Post 3482273)
Somewhere nearby, you'll find a file named: Makefile. Open it up, and have a look inside. (But don't touch anything...)

You'll find the word install in there somewhere... it's what we call a make target. You'll also probably find other make-targets, like all and clean.

In any case, the essential information that you find in a Makefile is: "what depends on what, and if you determine that something needs to be rebuilt, how do you do it?"

Thus, for example, when you say make install, the "make" utility is going to find that target, and work backwards to see what prerequisites there are, and to determine whether those prerequisite steps have already been done. For instance, if the program hasn't been compiled yet, that will happen first, then the stuff will be "installed." (And the Makefile will specify exactly how to do that.)

make is one of those utilities for which the concept is intuitively simple, and the implementation can be quite complex indeed. (And we haven't even touched on configure!) In any case, we can usually stick to the "intuitively simple," namely, "it just works." You can just tell it what to make, and ... sit back and watch the pretty blinking lights.

Ah, now that does make things a lot simpler ;) . I never realized that multiple targets were contained in one Makefile. (We have to use make clean all the time, and it never occurred to me that clean might actually be a target, and not some special case of the make command)

Again, thanks for the awesome answers - you guys have really helped me get this a lot better.


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