4

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.

4
  • 1
    As a very basic solution, install them locally for you and add them to your include path Commented Aug 14, 2014 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"? Commented Aug 14, 2014 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. Commented Aug 14, 2014 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. Commented Aug 14, 2014 at 8:47

1 Answer 1

5

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
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.

6
  • 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? Commented Aug 14, 2014 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. Commented Aug 14, 2014 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.) Commented Aug 14, 2014 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' Commented Aug 14, 2014 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? Commented Aug 14, 2014 at 8:47

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.