Installation instructions for the rjags package
-----------------------------------------------

The rjags package is an interface to the JAGS library.  In order to
build a binary package, or install from source, you must have a matching
installation of the JAGS library.

Contents:

1 Windows
2 Unix/Linux: pkg-config
3 Unix/Linux: runtime linkage

1 Windows
---------

If you are installing the Windows binary rjags package, then R will
consult the Windows registry to find the location of JAGS.
Alternatively, you can specify the location of JAGS by setting the
environment variable JAGS_HOME.

If you are compiling the rjags package from source on Windows then you must
supply the location of JAGS using the make variable JAGS_HOME, by adding a
line such as

JAGS_HOME=c:/Progra~1/JAGS/JAGS-5.0.0

to the file HOME/.R/Makevars.win, where HOME is the default starting
directory for an R session launched from the start menu (typically
your Documents folder).

2 Unix/Linux: pkg-config
------------------------

The configure script uses pkg-config to detect the JAGS library and
set the compiler and linker flags for rjags. You can test this
capability in a unix shell by typing

pkg-config --modversion jags

If this does not detect your JAGS installation then it means that the
file 'jags.pc' is not on the search path of pkg-config. In this case
you should add it by setting the environment variable PKG_CONFIG_PATH.
For example if the full path to 'jags.pc' is
'/usr/local/lib64/pkgconfig/jags.pc', then set

export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig

before installing rjags.

Recall that most Linux distributions divide software into `user' and
`developer' versions, so if you are using a pre-built JAGS binary
package for your Linux distribution then remember to install the
developer version before attempting to install the rjags package.

3 Unix/Linux: runtime linkage
-----------------------------

Although pkg-config helps to find the right flags for linking to the
JAGS library at compile time, it does not help at runtime. In order to
detect potential problems with runtime linkage, the configure script
of the rjags package will compile and run a test program that links to
the JAGS library. If this fails with the message "runtime link error"
then you may take the following actions to fix the problem:

If you have administrative privileges (sudo or root access):

1) Add the directory containing the JAGS library to the linker path,
   typically by editing the file /etc/ld.so.conf.

2) If the directory is already on the linker path then you may 
   need to run /sbin/ldconfig as root to update the linker cache.

If you do not have administrative privileges:

3) Set the environment variable LD_RUN_PATH to the directory
   containing the JAGS library before installing rjags, or

4) On Linux, you may use the --enable-rpath option, i.e. from
   the unix shell:

   R CMD INSTALL --configure-args='--enable-rpath' rjags

   or, within R

   > install.packages("rjags", configure.args="--enable-rpath")

You may also consider:

5) Set the environment variable LD_LIBRARY_PATH to the directory
   containing the JAGS library.

   Unlike options 3) and 4) if you use LD_LIBRARY_PATH then it must be
   set every time you load the rjags package, not just at compile
   time. Thus it is best to set this in the file .bash_profile (or
   the equivalent file if you using another shell).
