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.

user541686
  • 3,083
  • 1
    As a very basic solution, install them locally for you and add them to your include path – martin Aug 14 '14 at 07: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"? – user541686 Aug 14 '14 at 07: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 07: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. – user541686 Aug 14 '14 at 08:47

1 Answers1

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.

Flexo
  • 374
  • 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? – user541686 Aug 14 '14 at 07: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 07: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.) – user541686 Aug 14 '14 at 07: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' – user541686 Aug 14 '14 at 08: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? – user541686 Aug 14 '14 at 08:47
  • @mehrdad in terms of how you reference the package if you specify the name of a binary package that's fine and it just picks the source that package was built from. For the missing package you've probably not set an environment variable right after doing the dependency. You can figure it out by reading config.log and seeing what arguments were given to the test that failed and working back from there to make sure the missing include or library is in the appropriate path. – Flexo Aug 14 '14 at 13:34