Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


Cannot build JAGS

Alan McKay
  • Alan McKay
    Alan McKay

    Hi folks,

    I should start by saying dammit Jim, I'm a Linux Systems Administrator, not a mathematician :-)

    I've got lots of experience building on Linux and UNIX before that, but I'm having a pretty basic problem with JAGS that I'm not sure how to resolve. One of the scientists I support says he wants a copy of JAGS built with ATLAS. Ok, great, so first I build ATLAS and in the process of doing that I got it to build LAPACK since that was an option for it.

    Now I have /data/binaries/solexa6/ATLAS-3.10.1/lib/, where "solexa6" is my node name. It seems that ATLAS wants to be built specifically for each machine so as to best optimize itself, so I can do that simply by maintaining paths for each machine. Simple.

    And I've got some stuff in there after building ATLAS
    [root@solexa6 JAGS-3.3.0]# ls /data/binaries/solexa6/ATLAS-3.10.1/lib/
    libatlas.a libcblas.a libf77blas.a liblapack.a libptcblas.a libptf77blas.a

    So now I try to configure JAGS and since it has an option for LAPACK I want to tell it where that library is :

    ./configure --prefix=/data/binaries/JAGS-3.3.0 --with-lapack=/data/binaries/solexa6/ATLAS-3.10.1/lib/liblapack.a

    but alas, it does not like that :

    checking for sgemm_ in -lblas... (cached) no
    checking for sgemm_ in -lblas... (cached) no
    configure: error: "You need to install the LAPACK library"
    [root@solexa6 JAGS-3.3.0]#

    So I also set this up and then ran LDCONFIG :
    [root@solexa6 JAGS-3.3.0]# cat /etc/ld.so.conf.d/ATLAS.conf

    and same results.

    I'm not sure what's up here - can anyone help.

    I'm on a RHEL5.7 box if that helps. Yes I know there are prebuild JAGS RPMs but my scientist wants JAGS built with ATLAS. And I understand just about enough of this stuff to get myself into trouble ...


    • Santiago


      I had similar problems that were finally fixed installing LAPACK and ATLAS Developer version. Try it!



      Last edit: Martyn Plummer 2013-04-26
  • Martyn Plummer
    Martyn Plummer

    Hi Alan,

    Most Linux distributions offer a version of Atlas that can be used as a drop-in replacement for blas. It may not be fully optimized to your particular hardware, but it is a lot easier than building it yourself.

    If you want to do it yourself you need the following options

    LDFLAGS="-L/data/binaries/solexa6/ATLAS-3.10.1/lib -lgfortran" \

    This tells the compiler to look for libraries in directory /data/binaries/solexa6/ATLAS-3.10.1/lib where your blas and lapack libraries are. The configure script will automatically search for atlas so there is no need to use the --with-blas or --with-lapack options.

    However, this will only work if you have compiled your atlas libraries with -fPIC. The jags executable does not depend on BLAS or LAPACK, but some of the dynamically loaded modules do: in order to link a shared library to your static libraries, they must contain relocatable code.

    If you have not done this, you can still build a statically linked version of jags by adding the configure option --disable-shared. This will allow you to use the command line interface, but not the R interface.

  • Alan McKay
    Alan McKay

    OK, thanks, I'll look at this today. I was pretty sure I'd tried the LDFLAGS trick but I'll double check to be sure. Will keep you posted on my progress ...

  • Alan McKay
    Alan McKay

    Well 5 months later and I'm back - sorry about the long delay :-/ Basically the scientist looking for this installation disappeared so I dropped it. And now he's reappeared so I'm picking it back up again.

    I tried putting LDFLAGS in front and I still get the error that I need to install the LAPACK library.

    Basically he wants R3.0.1 built with ATLAS and JAGS. And this seems to want LAPACK.

    I'm not really sure how to proceed here.

  • Martyn Plummer
    Martyn Plummer

    To find out what went wrong you need to look in the config.log file, although this is not always easy to read.

    Try the following instructions, which work for me, using JAGS 3.4.0 and the current stable version of atlas, version 3.10.1 (Note that the current development version of atlas, 3.11.11, will not work).

    Atlas only provides a partial implementation of LAPACK, but you can get a full LAPACK library by filling in the missing functions from the default LAPACK from netlib. This is really easy to do: just point to the lapack tarball from netlib during the configure step when you are building ATLAS. You also need to ensure that the code is PIC so it can be included in the dynamically loaded JAGS modules. This is done with the slightly arcane third line below:

    ../ATLAS/configure \
    --with-netlib-lapack-tarfile=/home/martyn/Downloads/lapack-3.4.2.tgz \
    -Fa alg '-fPIC'

    If all goes well, you should see the following lines in the configure output:

    checking if sgemm_ is being linked in already... no
    checking for ATL_xerbla in -latlas... yes
    checking for sgemm_ in -lf77blas... yes
    checking for cblas_dgemm in -lcblas... yes
    checking for cheev_... no
    checking for cheev_ in -llapack... yes

    Then do make; make install as usual.

    To configure JAGS to use ATLAS, just point LDFLAGS to the installation directory of ATLAS.

    LDFLAGS="-L/usr/local/lapack/lib -lgfortran" ./configure
    make install
  • Alan McKay
    Alan McKay

    Thanks. I do the same ATLAS configure command as you and it appears to complete fine. But my build is still not building and .so shared libraries.

    What should I look for in config.log?

  • Alan McKay
    Alan McKay

    Gah, sorry, getting my threads mixed up - I'll try the "--shared" option on configure and let you know.

  • Alan McKay
    Alan McKay

    Hmmm, I just posted something but it seems to have immediately disappeared - let me try again.

    I am back to square one. I'm building ATLAS as per above, however it is not building the lapack shared libraries, it is only building the static ones. THough it is doing the atlas shared ones.

    /data/src/ATLAS-3.10.1/configure --prefix=/data/binaries/${HH}/ATLAS-3.10.1 --with-netlib-lapack-tarfile=/data/src/lapack-3.4.2.tgz -Fa alg '-fPIC' --shared

    Where HH is my hostname (doing a custom build per host)

    [root@solexa5 build5]# ls -al lib/
    total 62816
    drwxr-xr-x+  2 root root       15 Sep 18 13:14 .
    drwxr-xr-x+ 12 root root       17 Sep 18 13:14 ..
    -rw-r--r--+  1 root root 11818274 Sep 18 13:13 libatlas.a
    -rw-r--r--+  1 root root   489284 Sep 18 13:10 libcblas.a
    -rw-r--r--+  1 root root   583672 Sep 18 13:12 libf77blas.a
    -rw-r--r--+  1 root root   642066 Sep 18 13:14 libf77refblas.a
    -rw-r--r--+  1 root root 10652918 Sep 18 13:12 liblapack.a
    -rw-r--r--+  1 root root   489850 Sep 18 13:13 libptcblas.a
    -rw-r--r--+  1 root root   584068 Sep 18 13:13 libptf77blas.a
    -rw-r--r--+  1 root root 10815844 Sep 18 13:14 libptlapack.a
    -rwxr-xr-x+  1 root root 13467950 Sep 18 13:14 libsatlas.so
    -rwxr-xr-x+  1 root root 13566762 Sep 18 13:14 libtatlas.so
    -rw-r--r--+  1 root root   522112 Sep 18 13:03 libtstatlas.a
    -rw-r--r--+  1 root root    15000 Sep 18 11:32 Makefile

    Not sure what is going wrong here ...

  • Alan McKay
    Alan McKay

    Oh yeah and here is my JAGS build line

    [root@solexa3 JAGS-3.3.0]# LDFLAGS="-L/data/binaries/${HH}/ATLAS-3.10.1/lib -lgfortran" ./configure
    [ bunch of stuff removed]
    configure: error: "You need to install the LAPACK library"

    So what do I look for in config.log?

  • Alan McKay
    Alan McKay

    Well I don't know how to read a config.log but here is there part before the error

    configure:22676: checking for cheev_ in -llapack_rs6k
    configure:22709: gcc -o conftest -g -O2  -L/data/binaries/solexa3/ATLAS-3.10.1/lib -lgfortran conftest.c -llapack_rs6k  -L/data/binaries/solexa3/ATLAS-3.10.1/lib -L/usr/lib/gcc/x86_64-redhat-linux/4.1.2 -L/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -lgfortran -lm -ldl -lgfortranbegin -lcblas -lf77blas -latlas -ldl  >&5
    /usr/bin/ld: cannot find -llapack_rs6k
    collect2: ld returned 1 exit status
    configure:22709: $? = 1
    configure: failed program was:
    | /* confdefs.h */
    | #define PACKAGE_NAME "JAGS"
    | #define PACKAGE_TARNAME "JAGS"
    | #define PACKAGE_VERSION "3.3.0"
    | #define PACKAGE_STRING "JAGS 3.3.0"
    | #define PACKAGE_BUGREPORT "martyn_plummer@users.sourceforge.net"
    | #define PACKAGE_URL ""
    | #define PACKAGE "JAGS"
    | #define VERSION "3.3.0"
    | #define STDC_HEADERS 1
    | #define HAVE_SYS_TYPES_H 1
    | #define HAVE_SYS_STAT_H 1
    | #define HAVE_STDLIB_H 1
    | #define HAVE_STRING_H 1
    | #define HAVE_MEMORY_H 1
    | #define HAVE_STRINGS_H 1
    | #define HAVE_INTTYPES_H 1
    | #define HAVE_STDINT_H 1
    | #define HAVE_UNISTD_H 1
    | #define HAVE_DLFCN_H 1
    | #define LT_OBJDIR ".libs/"
    | #define LT_MODULE_EXT ".so"
    | #define LT_DLSEARCH_PATH "/lib64:/usr/lib64:/lib:/usr/lib:/usr/lib64/atlas:/usr/lib64/mysql:/usr/lib64/qt-3.3/lib:/usr/lib/xulrunner-2:/usr/lib64/xulrunner-2:/usr/X11R6/lib64"
    | #define HAVE_LIBDL 1
    | #define HAVE_DLERROR 1
    | #define HAVE_LIBDLLOADER 1
    | #define HAVE_ARGZ_H 1
    | #define HAVE_ERROR_T 1
    | #define HAVE_ARGZ_ADD 1
    | #define HAVE_ARGZ_APPEND 1
    | #define HAVE_ARGZ_COUNT 1
    | #define HAVE_ARGZ_CREATE_SEP 1
    | #define HAVE_ARGZ_INSERT 1
    | #define HAVE_ARGZ_NEXT 1
    | #define HAVE_ARGZ_STRINGIFY 1
    | #define HAVE_WORKING_ARGZ 1
    | #define HAVE_UNISTD_H 1
    | #define HAVE_DIRENT_H 1
    | #define HAVE_CLOSEDIR 1
    | #define HAVE_OPENDIR 1
    | #define HAVE_READDIR 1
    | #define LT_LIBEXT "a"
    | #define LT_LIBPREFIX "lib"
    | #define YYTEXT_POINTER 1
    | #define HAVE_ISNAN 1
    | #define HAVE_DECL_ISFINITE 0
    | #define HAVE_DECL_ISNAN 1
    | #define IEEE_754 1
    | #define F77_FUNC(name,NAME) name ## _
    | #define F77_FUNC_(name,NAME) name ## _
    | #define HAVE_BLAS 1
    | /* end confdefs.h.  */
    | /* Override any GCC internal prototype to avoid an error.
    |    Use char because int might match the return type of a GCC
    |    builtin and then its argument prototype would still apply.  */
    | #ifdef __cplusplus
    | extern "C"
    | #endif
    | char cheev_ ();
    | #ifdef F77_DUMMY_MAIN
    | #  ifdef __cplusplus
    |      extern "C"
    | #  endif
    |    int F77_DUMMY_MAIN() { return 1; }
    | #endif
    | int
    | main ()
    | {
    | return cheev_ ();
    |   ;
    |   return 0;
    | }
    configure:22719: result: no
    configure:22740: error: "You need to install the LAPACK library"

    I think maybe this is the culprit?

    /usr/bin/ld: cannot find -llapack_rs6k
  • Alan McKay
    Alan McKay

    Did some googling on how to list symbols in a library

    [root@solexa3 JAGS-3.3.0]# nm /data/binaries/solexa3/ATLAS-3.10.1/lib/liblapack.a | grep -i rs6k

    That finds nothing

    Last edit: Alan McKay 2013-09-18
  • Alan McKay
    Alan McKay

    These are RHEL5 boxes BTW. Yeah, I know RHEL5? Really? SIgh.

    I went over to an Ubuntu 13.04 box and checked the symbols on the lapack library for the above string and it also finds nothing.

    I"m just kind of flailing about at this point ... as per my first statement above, I'm a Linux Sys Admin not a Mathematician.

    root@solexa1:~# nm /usr/lib/liblapack.a | grep -i rs6k
    root@solexa1:~# dpkg --list | grep -i lapack
    ii  liblapack-dev                             3.4.2-1~exp3                           amd64        Library of linear algebra routines 3 - static version
    ii  liblapack3                                3.4.2-1~exp3                           amd64        Library of linear algebra routines 3 - shared version
    ii  liblapack3gf                              3.4.2-1~exp3                           all          Transitional package for liblapack3
  • Alan McKay
    Alan McKay

    I can't find anything in google about this ... go just grepping in the distribution for rs6k I find this in the configure :

    # Generic LAPACK library?
    for lapack in lapack lapack_rs6k; do
            if test $ax_lapack_ok = no; then
                    save_LIBS="$LIBS"; LIBS="$BLAS_LIBS $LIBS"
                    as_ac_Lib=`$as_echo "ac_cv_lib_$lapack''_$cheev" | $as_tr_sh`
    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $cheev in -l$lapack" >&5
    $as_echo_n "checking for $cheev in -l$lapack... " >&6; }
    if eval \${$as_ac_Lib+:} false; then :
      $as_echo_n "(cached) " >&6
    LIBS="-l$lapack $FLIBS $LIBS"
    cat confdefs.h - <<_ACEOF >conftest.$ac_ext

    If I just remove that reference to lapack_rs6k maybe it will work?

    Let's see ...

  • Alan McKay
    Alan McKay

    Nope, that did not work. So I did this, and it also did not work :

    LDFLAGS="-L/usr/lib64 -L/usr/lib64/atlas -L/data/binaries/${HH}/ATLAS-3.10.1/lib -lgfortran" ./configure
    configure: error: "You need to install the LAPACK library"
  • Alan McKay
    Alan McKay

    Oh yeah I forgot to point this out : I have lapack from the RPMs

    [root@solexa3 JAGS-3.3.0]# locate liblapack
    [root@solexa3 JAGS-3.3.0]#
  • Martyn Plummer
    Martyn Plummer

    This is what it should look like:

    [martyn@braque ~]$ locate liblapack
    /usr/lib64/liblapack.so              <-----------
    /usr/lib64/atlas/liblapack.so        <-----------

    Note the two instances of liblapack.so which are missing from your system. These come from the lapack-devel and atlas-devel packages.

    [martyn@braque ~]$ rpm -q --file /usr/lib64/liblapack.so
    [martyn@braque ~]$ rpm -q --file /usr/lib64/atlas/liblapack.so

    As a systems administrator, you should know that RPM packages come in two flavours: user and developer. If you want to compile a program and link it to a library, then you always need the devopment version installed.

    You also need blas-devel, if you are going with vanilla blas/lapack.

  • Martyn Plummer
    Martyn Plummer

    As for your hunt for the missing rs6k symbol, you are very confused. The configure script is not looking for rs6k in the lapack library. It is always looking for the cheev symbol (possibly with an underscore, depending on your platform), and the last place it looks is a library called liblapack_rs6k. This does not exist on your system (or indeed mine).

  • Alan McKay
    Alan McKay

    So I dunno ... something really up with my system I guess because I get the same error when I just do
    and forget about all the ATLAS stuff.

    Is it looking for 32bit libraries maybe? And I only have 64?

  • Alan McKay
    Alan McKay

    Aha, I do know about the -devel stuff and I just discovered that "yum search" on this system does not show any of the devel RPMs. But I go to a sister system and indeed they show up :

    lapack.i386 : The LAPACK libraries for numerical linear algebra
    lapack.x86_64 : The LAPACK libraries for numerical linear algebra
    lapack-devel.i386 : LAPACK development libraries
    lapack-devel.x86_64 : LAPACK development libraries

    So this leaves me to figure out what is wrong with the system I've been trying to build this on - but of course that's not something you can help with :-) But I think it may finally lead me to a resolution. They are supposed to be identical systems ...

  • Alan McKay
    Alan McKay

    Damn ... yup it runs through fine on my other system.

    Now I need to add to my list to figure out what is borked on the first one ... or just reclone it and be done.

    Thanks for your patience and help.

  • Alan McKay
    Alan McKay

    Well this is interesting ... and I guess as far as you are concerned off topic at this point, but I just had to post it given how long this has taken me.

    I go to another cluster node and check and it is broken too - "yum search lapack" does not show any of the devel stuff. Which is why I never installed them.

    The one that works - I had converted from RHEL to CentOS about 2 weeks ago. Did not reinstall or anything - just did a live conversion.

    That's very interesting ...