Down, down, down
I have a package that depends on INLA, which has recently begun failing to load if rgdal
isn’t installed correctly. rgdal
can’t be installed without the GDAL library, which requires PROJ, which requires SQLite. I needed to install all of these on our cluster without root access. That meant compiling each one to a non-standard location, then ensuring that the next in the sequence knew where this was. It also meant that if I missed an option in, say SQLite, I had to start from the bottom and recompile everything.
Clawing my way out
This is what I eventually (after 2 days of work) got to work.
SQLite
- Download and untar the most recent SQLite amalgamation. I did not use the
autoconf
version. - Configure:
./configure --prefix=/usr/lusers/jkbest/inst/sqlite-3.33.0 \
"-DSQLITE_ENABLE_COLUMN_METADATA=1" CFLAGS=
Note the CFLAGS
here. Without that rgdal
will fail to install with a message about table_columns
or similar and you’ll need to start over from this step (ask me how I know!).
- Compile and install:
make -jN
make install
- Update
$PATH
s. In your.zshrc
,.bashrc
or similar, add entries toPATH
forbin
,LD_LIBRARY_PATH
forlib
,CPATH
forinclude
, andPKG_CONFIG_PATH
forlib/pkgconfig
. I don’t know which of these mattered, but it didn’t hurt to add them.
PROJ
Download and untar the latest version of PROJ.
Configure:
./configure --prefix=$INSTALL_PATH/proj-7.2.0 \
\
SQLITE3_CFLAGS=-I/usr/lusers/jkbest/inst/sqlite-3.33.0/include "-L/usr/lusers/jkbest/inst/sqlite-3.33.0/lib -lsqlite3" \
SQLITE3_LIBS=\
CPPFLAGS=-I/usr/lusers/jkbest/inst/sqlite-3.33.0/include "-L/usr/lusers/jkbest/inst/sqlite-3.33.0/lib -lsqlite3" LDFLAGS=
- Compile and install:
make
make install
- Update
PATH
,LD_LIBRARY_PATH
,PKG_CONFIG_PATH
, andCPATH
as described above.
GDAL
Download and untar the latest version of GDAL.
Configure:
./configure --prefix=/usr/lusers/jkbest/inst/gdal-3.2.0\
"-I/usr/lusers/jkbest/inst/proj-7.2.0/include -I/usr/lusers/jkbest/inst/sqlite-3.33.0/include"\
CFLAGS="-L/usr/lusers/jkbest/inst/proj-7.2.0/lib -lproj -L/usr/lusers/jkbest/inst/sqlite-3.33.0/lib -lsqlite3" \
LIBS="-I/usr/lusers/jkbest/inst/proj-7.2.0/include -I/usr/lusers/jkbest/inst/sqlite-3.33.0/include"\
CPPFLAGS="-L/usr/lusers/jkbest/inst/proj-7.2.0/lib -lproj -L/usr/lusers/jkbest/inst/sqlite-3.33.0/lib -lsqlite3" LDFLAGS=
- Compile and install (takes a while and benefits from multiple jobs):
make -jN
make install
- Update environmental variables.
rgdal
In R, run
install.packages("rgdal", configure.args = "--host=host")
No idea why the host
argument is necessary, but it errors with messages about cross-compiling if it is not included.
Fresh air
That was easy, right?