LinuxQuestions.org
Register a domain and help support LQ
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 11-26-2005, 10:56 AM   #1
yougene
Member
 
Registered: Oct 2005
Posts: 65

Rep: Reputation: 15
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?
 
Old 11-26-2005, 11:46 AM   #2
Sargek
Member
 
Registered: Jan 2003
Location: San Antonio, Texas
Distribution: Debian testing
Posts: 416

Rep: Reputation: 32
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.
 
Old 11-26-2005, 02:21 PM   #3
jrdioko
Member
 
Registered: Oct 2002
Distribution: Debian 6.0.2 (squeeze)
Posts: 944

Rep: Reputation: 30
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.
 
Old 11-26-2005, 02:36 PM   #4
Sargek
Member
 
Registered: Jan 2003
Location: San Antonio, Texas
Distribution: Debian testing
Posts: 416

Rep: Reputation: 32
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.
 
Old 11-26-2005, 02:48 PM   #5
ioerror
Member
 
Registered: Sep 2005
Location: Old Blighty
Distribution: Slackware, NetBSD
Posts: 536

Rep: Reputation: 30
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.
 
Old 11-26-2005, 02:54 PM   #6
jrdioko
Member
 
Registered: Oct 2002
Distribution: Debian 6.0.2 (squeeze)
Posts: 944

Rep: Reputation: 30
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.
 
Old 11-26-2005, 03:26 PM   #7
ioerror
Member
 
Registered: Sep 2005
Location: Old Blighty
Distribution: Slackware, NetBSD
Posts: 536

Rep: Reputation: 30
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.
 
Old 11-26-2005, 03:29 PM   #8
jrdioko
Member
 
Registered: Oct 2002
Distribution: Debian 6.0.2 (squeeze)
Posts: 944

Rep: Reputation: 30
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.
 
Old 11-26-2005, 04:00 PM   #9
ioerror
Member
 
Registered: Sep 2005
Location: Old Blighty
Distribution: Slackware, NetBSD
Posts: 536

Rep: Reputation: 30
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.
 
Old 11-26-2005, 06:32 PM   #10
Sargek
Member
 
Registered: Jan 2003
Location: San Antonio, Texas
Distribution: Debian testing
Posts: 416

Rep: Reputation: 32
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.
 
Old 11-27-2005, 09:23 AM   #11
ioerror
Member
 
Registered: Sep 2005
Location: Old Blighty
Distribution: Slackware, NetBSD
Posts: 536

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


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
Reducing size of /usr/local/src jrdioko Linux - Software 8 06-09-2005 11:42 PM
Installing software, /usr/lib directory and /usr/local millertime Linux - Software 2 07-10-2004 10:21 AM
Kernel Compiling not possible, Directory /usr/src/linux-2.4 isn't there rover Linux - Software 4 09-24-2003 09:05 AM
compiling a kernel somewhere other than /usr/src h/w Linux - Newbie 4 09-07-2003 07:34 PM
Creating /usr/src/linux-<xx> from kernel.<xx>.src.rpm jmourik Linux - Newbie 2 02-19-2003 04:24 PM


All times are GMT -5. The time now is 08:30 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration