Building things without root access
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.
Contents
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
perl -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 directories. An include file can be used to abbreviate this. I call mine LLIB.pm (for Local LIBraries):
BEGIN { my $sub = "perl/5.6.1"; my $super = "/user/inst"; unshift(@INC, "$super/lib/$sub", "$super/local/lib/$sub", "$super/share/$sub", "$super/local/share/$sub" ); } 1;
Then, using the libraries simply involves symlinking LLIB.pm to whatever directory your executable sits in and prefixing the code with
use LLIB;