Difference between revisions of "Building things without root access"

From HalfgeekKB
Jump to navigation Jump to search
Line 32: Line 32:
  
 
  perl Makefile.PL PREFIX=/user/inst
 
  perl Makefile.PL PREFIX=/user/inst
 +
 +
Actually, if what you're building depends on something else you've built this way, you'll also need to include other directories, as explained later.  We'll assume we've put that code in a file called LLIB.pm and conveniently symlinked that file to the build directory.  Now do
 +
 +
perk -MLLIB Makefile.PL PREFIX=/user/inst
  
 
Then, view the resulting Makefile.  Find what is already in CCFLAGS and LDDLFLAGS.  For example,
 
Then, view the resulting Makefile.  Find what is already in CCFLAGS and LDDLFLAGS.  For example,

Revision as of 02:45, 29 June 2005

Here are a few notes on building C programs on a system you don't own and don't have root access to. Obviously, this has a few strange operational implications.

A pseudo-root

I'll be building things using a subdirectory of my home dir, /user/inst, as the basis of everything (basically replacing what would be /usr/local in normal installs).

./configure

If the autoconf variables are typical, things should run correctly by

./configure --prefix=/user/inst
make
make install

Run ./configure --help to find out if there are more variables to set.

Compiling based on non-global libs

Compiling a simple program based on Gnu MP normally looks like this:

gcc -o sample sample.c -lgmp

Add some things to make it work using your own version:

gcc -o sample sample.c -lgmp -I- -I/user/inst/include -L/user/inst/lib

Any normal -I switches should come before -I-. The -I- is optional if you use the header name in quotes instead of angles.

Compiling CPAN Modules

This one is tricky. Start by running

perl Makefile.PL PREFIX=/user/inst

Actually, if what you're building depends on something else you've built this way, you'll also need to include other directories, as explained later. We'll assume we've put that code in a file called LLIB.pm and conveniently symlinked that file to the build directory. Now do

perk -MLLIB Makefile.PL PREFIX=/user/inst

Then, view the resulting Makefile. Find what is already in CCFLAGS and LDDLFLAGS. For example,

LDDLFLAGS = -shared -L/usr/local/lib
CCFLAGS = -DDEBIAN -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64

Change them as necessary.

LDDLFLAGS = -shared -L/user/inst/include -L/usr/local/lib
CCFLAGS = -DDEBIAN -fno-strict-aliasing -I/user/inst/include -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64

make and make install should then run as expected. To use the resulting module, you'll have to indicate your local libraries directory:

use lib '/user/inst/local/lib/perl/5.6.1','/user/inst/share/perl/5.6.1';

An include file can be used to abbreviate this:

BEGIN {
  my $sub = "perl/5.6.1";
  my $super = "/user/inst";
  unshift(@INC, "$super/local/lib/$sub", "$super/share/$sub");
}
1;