Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

How should I go about compiling programs that depend on libraries whose development packages (headers and such) aren't pre-installed on the system when I don't have sudo access?

In this particular case I have Ubuntu 12.04, but I'm hoping for a more general solution, because it seems bizarre to me that I would need administrator privileges just to install the dev packages so I can compile.

share|improve this question

migrated from stackoverflow.com Aug 14 '14 at 8:01

This question came from our site for professional and enthusiast programmers.

marked as duplicate by jasonwryan, cuonglm, slm Aug 14 '14 at 12:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

As a very basic solution, install them locally for you and add them to your include path – martin Aug 14 '14 at 7:46
@martin: "Install them locally"? I didn't know you can install packages locally... I just install them with sudo apt-get install package-dev; how do I install them "locally"? – Mehrdad Aug 14 '14 at 7:54
@Mehrdad Install them locally (while better solutions might exist) consists in compiling each of them on your own, similar to Flexo's answer. – martin Aug 14 '14 at 7:57
@jasonwryan: Not quite, I'm talking about development packages, not ordinary programs. It's about the development workflow, not just a question about apt-get. – Mehrdad Aug 14 '14 at 8:47

On Debian derived systems you can get the source (even as a non root user) using apt-get source provided sources.list has some deb-src entries. Otherwise it's stuck with downloading from the project source repository with standard tools.

Once you've got that source then:

./configure --prefix=/home/me/mysoftware
make install

Will work for most source distributions using autotools or similar.

Once you've done that you'll want to set LD_LIBRARY_PATH and PATH environment variables in your profile.

When you configure other things that depend on software installed in this way you'll need to set PKG_CONFIG_PATH, CFLAGS, CXXFLAGS, LDFLAGS and possibly use other configure arguments to "help" configure find your special install path.

Of course it might be easier just to open a support ticket for someone with the power of root.

share|improve this answer
I guess I should've mentioned, half of the program is figuring out how to get the correct headers and such before I can point to the directory. With sudo it's pretty easy: sudo apt-get install blah-dev, but how do I get the correct sources when I can't do that? – Mehrdad Aug 14 '14 at 7:53
You're stuck with two options: apt-get source doesn't need root, but that's ugly compared to just opening a support ticket or wget and the URL to the tarball you want. – Flexo Aug 14 '14 at 7:55
Oh I didn't know about apt-get source... I'll give that a try, thanks. +1 (I can't exactly open a support ticket in my situation.) – Mehrdad Aug 14 '14 at 7:59
Sorry I'm a little confused, am I supposed to specify the -dev packages here, or the normal packages? Because I just tried apt-get source libxrandr-dev and I got Picking 'libxrandr' as source package instead of 'libxrandr-dev' – Mehrdad Aug 14 '14 at 8:33
I'm also really confused... I tried running ./configure --prefix="$HOME/usr" but then it told me No package 'xorg-macros' found... so I downloaded the source for xutils-dev (which seems to be what contains xorg-macros?) and cd'd into ./xutils-dev-7.7~1/util-macros/ and then ran ./configure --prefix="$HOME/usr" and make install there. Which ran fine, but didn't seem to fix the missing package issue whatsoever... did I miss a step? Am I going about it correctly? – Mehrdad Aug 14 '14 at 8:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.