Difference between revisions of "Building things without root access"
Line 25: | Line 25: | ||
gcc -o sample sample.c -lgmp -I- -I/user/inst/include -L/user/inst/lib | gcc -o sample sample.c -lgmp -I- -I/user/inst/include -L/user/inst/lib | ||
− | Any normal -I switches should come before -I-. | + | Any normal -I switches should come before -I-. The -I- is optional if you use the header name is quotes instead of angles. |
+ | |||
+ | =Compiling CPAN Modules= | ||
+ | |||
+ | This one is tricky. Start by running | ||
+ | |||
+ | perl 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; |
Revision as of 15:18, 10 May 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.
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 a couple 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 is quotes instead of angles.
Compiling CPAN Modules
This one is tricky. Start by running
perl 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;