FreeBSD rjags installation problems

  • the_snake

    the_snake - 2014-06-07

    Hi. I'm having problems installing rjags 3-13 on FreeBSD 10 with R 3.0.2 and mcmc-jags-3.4.0_2. Any help would be greatly appreciated. Here's what I've tried so far.

    1. Installing from within R (R run as root).

    Even though I performed standard installation of JAGS (pkg install mcmc-jags) I still needed to specify the "--with" arguments below or it would complain. Not sure if it's supposed to complain.

    > install.packages("rjags", repos="", configure.args="--with-jags-include=/usr/local/include/JAGS --with-jags-lib=/usr/local/lib/JAGS --with-jags-modules=/usr/local/lib/JAGS/modules-3", dependencies=T)
    trying URL ''
    Content type 'application/x-gzip' length 66753 bytes (65 Kb)
    opened URL
    downloaded 65 Kb
    * installing *source* package 'rjags' ...
    ** package 'rjags' successfully unpacked and MD5 sums checked
    checking for prefix by checking for jags... no
    checking whether the C++ compiler works... yes
    checking for C++ compiler default output file name... a.out
    checking for suffix of executables...
    checking whether we are cross compiling... no
    checking for suffix of object files... o
    checking whether we are using the GNU C++ compiler... yes
    checking whether g++47 accepts -g... yes
    checking how to run the C++ preprocessor... g++47 -E
    checking for grep that handles long lines and -e... /usr/bin/grep
    checking for egrep... /usr/bin/grep -E
    checking for ANSI C header files... yes
    checking for sys/types.h... yes
    checking for sys/stat.h... yes
    checking for stdlib.h... yes
    checking for string.h... yes
    checking for memory.h... yes
    checking for strings.h... yes
    checking for inttypes.h... yes
    checking for stdint.h... yes
    checking for unistd.h... yes
    checking Console.h usability... yes
    checking Console.h presence... yes
    checking for Console.h... yes
    checking for gcc... gcc47 -std=gnu99
    checking whether we are using the GNU C compiler... yes
    checking whether gcc47 -std=gnu99 accepts -g... yes
    checking for gcc47 -std=gnu99 option to accept ISO C89... none needed
    checking for jags_version in -ljags... yes
    configure: creating ./config.status
    config.status: creating src/Makevars
    configure: creating ./config.status
    config.status: creating src/Makevars
    config.status: creating R/unix/zzz.R
    ** libs
    g++47 -I/usr/local/lib/R/include -DNDEBUG -I/usr/local/include/JAGS -I/usr/local/include -DLIBICONV_PLUG    -fpic  -O2 -pipe -fno-builtin-coshl -fno-builtin-erfcl -fno-builtin-erfl -fno-builtin-lgammal -fno-builtin-powl -fno-builtin-sinhl -fno-builtin-tanhl -fno-builtin-tgammal -DLIBICONV_PLUG -Wl,-rpath=/usr/local/lib/gcc47 -fno-strict-aliasing -DLIBICONV_PLUG -Wl,-rpath=/usr/local/lib/gcc47  -c -o jags.o
    g++47 -I/usr/local/lib/R/include -DNDEBUG -I/usr/local/include/JAGS -I/usr/local/include -DLIBICONV_PLUG    -fpic  -O2 -pipe -fno-builtin-coshl -fno-builtin-erfcl -fno-builtin-erfl -fno-builtin-lgammal -fno-builtin-powl -fno-builtin-sinhl -fno-builtin-tanhl -fno-builtin-tgammal -DLIBICONV_PLUG -Wl,-rpath=/usr/local/lib/gcc47 -fno-strict-aliasing -DLIBICONV_PLUG -Wl,-rpath=/usr/local/lib/gcc47  -c -o parallel.o
    g++47 -fpic -shared -L/usr/local/lib -fno-builtin-coshl -fno-builtin-erfcl -fno-builtin-erfl -fno-builtin-lgammal -fno-builtin-powl -fno-builtin-sinhl -fno-builtin-tanhl -fno-builtin-tgammal -Wl,-rpath=/usr/local/lib/gcc47 -L/usr/local/lib/gcc47 -B/usr/local/bin -Wl,-rpath=/usr/local/lib/gcc47 -L/usr/local/lib/gcc47 -o jags.o parallel.o -L/usr/local/lib/JAGS -ljags -L/usr/local/lib/R/lib -lR
    installing to /usr/local/lib/R/library/rjags/libs
    ** R
    ** data
    ** preparing package for lazy loading
    ** help
    *** installing help indices
    ** building package indices
    Warning: namespace 'rjags' is not available and has been replaced
    by .GlobalEnv when processing object 'LINE'
    ** testing if installed package can be loaded
    Error : .onLoad failed in loadNamespace() for 'rjags', details:
      call: dyn.load(file, DLLpath = DLLpath, ...)
      error: unable to load shared object '/usr/local/lib/R/library/rjags/libs/':
      /usr/local/lib/R/library/rjags/libs/ Undefined symbol "_ZN7Console10loadModuleERKSs"
    Error: loading failed
    Execution halted
    ERROR: loading failed
    * removing '/usr/local/lib/R/library/rjags'
    The downloaded source packages are in
    Updating HTML index of packages in '.Library'
    Making 'packages.html' ... done
    Warning message:
    In install.packages("rjags", repos = "",  :
      installation of package 'rjags' had non-zero exit status

    2. Installing from the command line:

    Tried it just for the hell of it, but I got the same result:

    R CMD INSTALL --configure-args="--with-jags-include=/usr/local/include/JAGS --with-jags-lib=/usr/local/lib/JAGS --with-jags-modules=/usr/local/lib/JAGS/modules-3 --enable-rpath" rjags_3-13.tar.gz

    3. Additional info:

    Using "--enable-rpath" changes nothing.

    > sessionInfo()
    R version 3.0.2 Patched (2013-11-12 r64207)
    Platform: amd64-portbld-freebsd10.0 (64-bit)
    [1] C
    attached base packages:
    [1] stats     graphics  grDevices utils     datasets  methods   base
    loaded via a namespace (and not attached):
    [1] tools_3.0.2


    # ldconfig -r | grep jags
    210:-ljags.3 => /usr/local/lib/
    Last edit: the_snake 2014-06-07
  • Martyn Plummer

    Martyn Plummer - 2014-06-08

    The rjags package is compiling correctly but not loading. If it compiles then you have the correct configure arguments (and you may not need all the ones you have given). Load errors normally indicate problems with the linker.

    The key error message is here:

    /usr/local/lib/R/library/rjags/libs/ Undefined symbol "_ZN7Console10loadModuleERKSs"

    Check that the dependencies of are found by the linker

    ldd /usr/local/lib/

    Make sure that this symbol is indeed in the JAGS library

    nm /usr/local/lib/ | grep loadModule
  • the_snake

    the_snake - 2014-06-08

    Thanks a lot for your fast response, Martyn! I really appreciate it! It looks like all dependencies of the JAGS library are discovered by the linker:

    # ldd /usr/local/lib/
   => /usr/lib/ (0x801693000)
   => /lib/ (0x80194e000)
   => /lib/ (0x801b68000)
   => /lib/ (0x80081d000)
   => /usr/local/lib/gcc47/ (0x801d8e000)

    Here are the relevant symbols from the library:

    # nm /usr/local/lib/ | grep loadModule
    000000000002fc20 T _ZN7Console10loadModuleERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE
    000000000002fe00 T _ZN7Console12unloadModuleERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE

    There is a name mismatch between the first of these symbols and the required symbol (i.e., _ZN7Console10loadModuleERKSs). Or am I reading this incorrectly?

    Last edit: the_snake 2014-06-08
  • Martyn Plummer

    Martyn Plummer - 2014-06-08

    The symbols do not match. Everything after "ERK" is different and you can see that the symbol name in the jags library is much longer.

    I see that libjags is linked against which means that it was built with clang++, whereas you are trying to build the rjags package with g++. You can't mix and match the two compilers this way.

    You need to either compile libjags with g++47 or configure R to use clang++ as its C++ compiler.

  • the_snake

    the_snake - 2014-06-08

    Ah, I see. Let me try these two options then. Thanks a lot for your help!

  • the_snake

    the_snake - 2014-06-10

    I tried the second option, i.e., compiling rjags with clang++ and it worked. The package loads now. Thanks again, Martyn! In case someone else finds themselves in a similar predicament, here's what did the trick:

    install.packages("rjags", repos="", configure.args="--with-jags-include=/usr/local/include/JAGS --with-jags-lib=/usr/local/lib --with-jags-modules=/usr/local/lib/JAGS/modules-3", dependencies=T)

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks