LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Compiling in /usr/local/src (https://www.linuxquestions.org/questions/linux-newbie-8/compiling-in-usr-local-src-386681/)

yougene 11-26-2005 09:56 AM

Compiling in /usr/local/src
 
I have read somewhere that I should compile in /usr/local/src but I've had some success in compiling in my /root directory. Will some programs just not compile anywhere else?

Sargek 11-26-2005 10:46 AM

Re: Compiling in /usr/local/src
 
Quote:

Originally posted by yougene
I have read somewhere that I should compile in /usr/local/src but I've had some success in compiling in my /root directory. Will some programs just not compile anywhere else?
I have never heard this. The only thing I have ever heard about compiling in a specific directory was an email I read from Linus Torvalds about not compiling kernels in the /usr/src directory, but that was a very old email. I've been compiling kernels in /usr/src for years, and other code in many other directories, without issue.

Does your statement "I've had some success in compiling in my /root directory" mean you are compiling as root, or did you mean you are compiling in the root of your user's home directory? You do not have to be root to compile anything, except a kernel if you are compiling in /usr/src, and even then you should be su'd to root, not actually logged in as root.

jrdioko 11-26-2005 01:21 PM

For applications you download yourself as additions to your system, the suggested place (I believe) to download and compile them is /usr/local/src. That will place all the files in the appropriate places in the /usr/local tree. That doesn't mean that you're not allowed to compile things in other places, and, as Sargek said above, sometimes the suggested place is somewhere else, like /usr/src for the kernel or maybe even ~/src for your own code. I suppose technically you could put anything in any directory and then just put a lot of work into making sure everything can find all its required libraries and such, but it helps organize your system to follow the directory structure.

Sargek 11-26-2005 01:36 PM

Quote:

Originally posted by jrdioko
For applications you download yourself as additions to your system, the suggested place (I believe) to download and compile them is /usr/local/src. That will place all the files in the appropriate places in the /usr/local tree. That doesn't mean that you're not allowed to compile things in other places, and, as Sargek said above, sometimes the suggested place is somewhere else, like /usr/src for the kernel or maybe even ~/src for your own code. I suppose technically you could put anything in any directory and then just put a lot of work into making sure everything can find all its required libraries and such, but it helps organize your system to follow the directory structure.
This is true - I've just never compiled anything in a system area - always used my home dir, because you should not have to be root to compile, and this gets noobs out of the habit of running as root. I always specifiy configure optiions when I compile anyway:
Code:

./configure --prefix=/your install path
Or wherever you would like the compiled binary to be installed. I always install in /opt, but that's a hold-over from my CRUX days. /usr/local is fine too.

ioerror 11-26-2005 01:48 PM

It doesn't make any difference where you compile source code. I tend to use /usr/local/src, I keep tarballs in /usr/local/src/Arc and I put compiled packages in /usr/local/src/Packages (in case I need to reinstall something). But it doesn't matter. You can compile anywhere.

Quote:

For applications you download yourself as additions to your system, the suggested place (I believe) to download and compile them is /usr/local/src. That will place all the files in the appropriate places in the /usr/local tree
The directory used to compile and the directory tree the package will reside in are totally unrelated.

Quote:

You do not have to be root to compile anything, except a kernel if you are compiling in /usr/src
I never compile anything as root. I just chown /usr/src to my uid. The only thing I can thing of that needs to be compiled as root is svgalib.

jrdioko 11-26-2005 01:54 PM

Quote:

Originally posted by ioerror
The directory used to compile and the directory tree the package will reside in are totally unrelated.
True, but it makes more sense to me to do the compiling in the same tree I'll be installing to rather than having to remember to pass prefixes to ./configure every time. Either way is fine, though.

ioerror 11-26-2005 02:26 PM

Quote:

rather than having to remember to pass prefixes to ./configure every time
Why do you need to use a prefix ?

The majority of packages install in /usr/local, so unless you want to install somewhere else, you don't need a prefix. Where you compile the src is irrelevant.

jrdioko 11-26-2005 02:29 PM

Never thought about that, just assumed it worked that way since I've always done it in /usr/local/src. Either way, I still like to put things in the directory where they seem to logically belong, but whatever makes most sense to the person who's doing the compiling... Linux is all about flexibility.

ioerror 11-26-2005 03:00 PM

Quote:

Either way, I still like to put things in the directory where they seem to logically belong,
Agreed. I tend to compile the kernel (and third party modules etc) in /usr/src, my own src in ~/src and everything else in /usr/local/src. But it makes no difference to the src.

Sargek 11-26-2005 05:32 PM

usr
 
Quote:

Originally posted by ioerror
It doesn't make any difference where you compile source code. I tend to use /usr/local/src, I keep tarballs in /usr/local/src/Arc and I put compiled packages in /usr/local/src/Packages (in case I need to reinstall something). But it doesn't matter. You can compile anywhere.



The directory used to compile and the directory tree the package will reside in are totally unrelated.



I never compile anything as root. I just chown /usr/src to my uid. The only thing I can thing of that needs to be compiled as root is svgalib.

I assumed since you mentioned you compiled in /usr/src, you were doing so as root. I am a security nut and never change any permissions outside of my /home dir, so have a build directory in my /home dir where I compile things I need to. I use Gentoo, so it is quite rare for me to install something that is not contained in Portage, but when I do, I always install in /opt. As I mentioned, the /opt thing is a CRUX hold-over, but it's in my path so works like a champ. Personal preference.

ioerror 11-27-2005 08:23 AM

Quote:

I assumed since you mentioned you compiled in /usr/src, you were doing so as root
No, I chown /usr/src to my uid. Dunno why really, I could just use ~ or /usr/local/src, I've just always used /usr/src for the kernel.


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