Beachmat install / compile issue
3
0
Entering edit mode
@danielgaffney-14911
Last seen 6.5 years ago

Hi,

I am getting a compilation error when installing beachmat on a clean install (i.e. downloaded and compiled the 3.4.3 source, reinstalled all packages from scratch) of R-3.4.3. My gcc version is 4.6.3. (Ubuntu/Linaro 4.6.3-1ubuntu5). Compilation seems to fail when it reaches the compilation step for "integer_matrix.cpp" as follows:

packageVersion("Rcpp")

[1] ‘0.12.15’

packageVersion("Rhdf5lib")

[1] ‘1.0.0’

biocLite("beachmat")

BioC_mirror: https://bioconductor.org

Using Bioconductor 3.6 (BiocInstaller 1.28.0), R 3.4.3 (2017-11-30).

Installing package(s) ‘beachmat’

trying URL 'https://bioconductor.org/packages/3.6/bioc/src/contrib/beachmat_1.0.2.tar.gz'

Content type 'application/x-gzip' length 75131 bytes (73 KB)

==================================================

downloaded 73 KB

 

* installing *source* package ‘beachmat’ ...

** libs

g++ -std=gnu++0x -I/nfs/users/nfs_d/dg13/local/lib/R/include -DNDEBUG  -I"/nfs/teams/team170/Daniel/local/lib/R/library/Rcpp/include" -I"/nfs/teams/team170/Daniel/local/lib/R/library/Rhdf5lib/include" -I/usr/local/include   -fpic  -g -O2 -c HDF5_utils.cpp -o HDF5_utils.o

g++ -std=gnu++0x -I/nfs/users/nfs_d/dg13/local/lib/R/include -DNDEBUG  -I"/nfs/teams/team170/Daniel/local/lib/R/library/Rcpp/include" -I"/nfs/teams/team170/Daniel/local/lib/R/library/Rhdf5lib/include" -I/usr/local/include   -fpic  -g -O2 -c any_matrix.cpp -o any_matrix.o

g++ -std=gnu++0x -I/nfs/users/nfs_d/dg13/local/lib/R/include -DNDEBUG  -I"/nfs/teams/team170/Daniel/local/lib/R/library/Rcpp/include" -I"/nfs/teams/team170/Daniel/local/lib/R/library/Rhdf5lib/include" -I/usr/local/include   -fpic  -g -O2 -c character_matrix.cpp -o character_matrix.o

g++ -std=gnu++0x -I/nfs/users/nfs_d/dg13/local/lib/R/include -DNDEBUG  -I"/nfs/teams/team170/Daniel/local/lib/R/library/Rcpp/include" -I"/nfs/teams/team170/Daniel/local/lib/R/library/Rhdf5lib/include" -I/usr/local/include   -fpic  -g -O2 -c character_output.cpp -o character_output.o

g++ -std=gnu++0x -I/nfs/users/nfs_d/dg13/local/lib/R/include -DNDEBUG  -I"/nfs/teams/team170/Daniel/local/lib/R/library/Rcpp/include" -I"/nfs/teams/team170/Daniel/local/lib/R/library/Rhdf5lib/include" -I/usr/local/include   -fpic  -g -O2 -c find_chunks.cpp -o find_chunks.o

g++ -std=gnu++0x -I/nfs/users/nfs_d/dg13/local/lib/R/include -DNDEBUG  -I"/nfs/teams/team170/Daniel/local/lib/R/library/Rcpp/include" -I"/nfs/teams/team170/Daniel/local/lib/R/library/Rhdf5lib/include" -I/usr/local/include   -fpic  -g -O2 -c functions.cpp -o functions.o

g++ -std=gnu++0x -I/nfs/users/nfs_d/dg13/local/lib/R/include -DNDEBUG  -I"/nfs/teams/team170/Daniel/local/lib/R/library/Rcpp/include" -I"/nfs/teams/team170/Daniel/local/lib/R/library/Rhdf5lib/include" -I/usr/local/include   -fpic  -g -O2 -c integer_matrix.cpp -o integer_matrix.o

In file included from integer_matrix.h:4:0,

                 from integer_matrix.cpp:1:

LIN_matrix.h:126:1: error: expected unqualified-id before ‘using’

LIN_matrix.h:129:1: error: expected unqualified-id before ‘using’

In file included from integer_matrix.cpp:1:0:

integer_matrix.h:21:9: error: ‘Rle_lin_matrix’ does not name a type

integer_matrix.cpp: In function ‘std::unique_ptr<beachmat::lin_matrix<int, Rcpp::Vector<13> > > beachmat::create_integer_matrix(const RObject&)’:

integer_matrix.cpp:25:84: error: no matching function for call to ‘std::unique_ptr<beachmat::lin_matrix<int, Rcpp::Vector<13> > >::unique_ptr(int*)’

integer_matrix.cpp:25:84: note: candidates are:

/usr/include/c++/4.6/bits/unique_ptr.h:164:2: note: template<class _Up, class> std::unique_ptr::unique_ptr(std::auto_ptr<_Up>&&)

/usr/include/c++/4.6/bits/unique_ptr.h:155:2: note: template<class _Up, class _Ep, class> std::unique_ptr::unique_ptr(std::unique_ptr<_Up, _Ep>&&)

/usr/include/c++/4.6/bits/unique_ptr.h:142:7: note: std::unique_ptr<_Tp, _Dp>::unique_ptr(std::unique_ptr<_Tp, _Dp>&&) [with _Tp = beachmat::lin_matrix<int, Rcpp::Vector<13> >, _Dp = std::default_delete<beachmat::lin_matrix<int, Rcpp::Vector<13> > >, std::unique_ptr<_Tp, _Dp> = std::unique_ptr<beachmat::lin_matrix<int, Rcpp::Vector<13> > >]

/usr/include/c++/4.6/bits/unique_ptr.h:142:7: note:   no known conversion for argument 1 from ‘int*’ to ‘std::unique_ptr<beachmat::lin_matrix<int, Rcpp::Vector<13> > >&&’

/usr/include/c++/4.6/bits/unique_ptr.h:136:17: note: constexpr std::unique_ptr<_Tp, _Dp>::unique_ptr(std::nullptr_t) [with _Tp = beachmat::lin_matrix<int, Rcpp::Vector<13> >, _Dp = std::default_delete<beachmat::lin_matrix<int, Rcpp::Vector<13> > >, std::nullptr_t = std::nullptr_t]

/usr/include/c++/4.6/bits/unique_ptr.h:136:17: note:   no known conversion for argument 1 from ‘int*’ to ‘std::nullptr_t’

/usr/include/c++/4.6/bits/unique_ptr.h:130:7: note: std::unique_ptr<_Tp, _Dp>::unique_ptr(std::unique_ptr<_Tp, _Dp>::pointer, typename std::remove_reference<_Dp>::type&&) [with _Tp = beachmat::lin_matrix<int, Rcpp::Vector<13> >, _Dp = std::default_delete<beachmat::lin_matrix<int, Rcpp::Vector<13> > >, std::unique_ptr<_Tp, _Dp>::pointer = beachmat::lin_matrix<int, Rcpp::Vector<13> >*, typename std::remove_reference<_Dp>::type = std::default_delete<beachmat::lin_matrix<int, Rcpp::Vector<13> > >]

/usr/include/c++/4.6/bits/unique_ptr.h:130:7: note:   candidate expects 2 arguments, 1 provided

/usr/include/c++/4.6/bits/unique_ptr.h:125:7: note: std::unique_ptr<_Tp, _Dp>::unique_ptr(std::unique_ptr<_Tp, _Dp>::pointer, typename std::conditional<std::is_reference<_Dp>::value, _Dp, const _Dp&>::type) [with _Tp = beachmat::lin_matrix<int, Rcpp::Vector<13> >, _Dp = std::default_delete<beachmat::lin_matrix<int, Rcpp::Vector<13> > >, std::unique_ptr<_Tp, _Dp>::pointer = beachmat::lin_matrix<int, Rcpp::Vector<13> >*, typename std::conditional<std::is_reference<_Dp>::value, _Dp, const _Dp&>::type = const std::default_delete<beachmat::lin_matrix<int, Rcpp::Vector<13> > >&]

/usr/include/c++/4.6/bits/unique_ptr.h:125:7: note:   candidate expects 2 arguments, 1 provided

/usr/include/c++/4.6/bits/unique_ptr.h:120:7: note: std::unique_ptr<_Tp, _Dp>::unique_ptr(std::unique_ptr<_Tp, _Dp>::pointer) [with _Tp = beachmat::lin_matrix<int, Rcpp::Vector<13> >, _Dp = std::default_delete<beachmat::lin_matrix<int, Rcpp::Vector<13> > >, std::unique_ptr<_Tp, _Dp>::pointer = beachmat::lin_matrix<int, Rcpp::Vector<13> >*]

/usr/include/c++/4.6/bits/unique_ptr.h:120:7: note:   no known conversion for argument 1 from ‘int*’ to ‘beachmat::lin_matrix<int, Rcpp::Vector<13> >*’

/usr/include/c++/4.6/bits/unique_ptr.h:114:17: note: constexpr std::unique_ptr<_Tp, _Dp>::unique_ptr() [with _Tp = beachmat::lin_matrix<int, Rcpp::Vector<13> >, _Dp = std::default_delete<beachmat::lin_matrix<int, Rcpp::Vector<13> > >]

/usr/include/c++/4.6/bits/unique_ptr.h:114:17: note:   candidate expects 0 arguments, 1 provided

integer_matrix.cpp:25:51: error: expected primary-expression before ‘(’ token

integer_matrix.cpp:25:56: error: expected type-specifier before ‘Rle_integer_matrix’

integer_matrix.cpp:25:56: error: expected ‘)’ before ‘Rle_integer_matrix’

make: *** [integer_matrix.o] Error 1

ERROR: compilation failed for package ‘beachmat’

* removing ‘/nfs/teams/team170/Daniel/local/lib/R/library/beachmat’

 

The downloaded source packages are in

    ‘/tmp/RtmpfPwli3/downloaded_packages’

Warning message:

In install.packages(pkgs = doing, lib = lib, ...) :

  installation of package ‘beachmat’ had non-zero exit status

Can anyone help?

Dan

beachmat compilation error • 3.3k views
ADD COMMENT
0
Entering edit mode

Apologies - the output of sessionInfo is:

 

sessionInfo()

R version 3.4.3 (2017-11-30)

Platform: x86_64-pc-linux-gnu (64-bit)

 

Matrix products: default

BLAS: /nfs/teams/team170/Daniel/local/lib/R/lib/libRblas.so

LAPACK: /nfs/teams/team170/Daniel/local/lib/R/lib/libRlapack.so

 

locale:

[1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              

[3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    

[5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   

[7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                 

[9] LC_ADDRESS=C               LC_TELEPHONE=C            

[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

 

attached base packages:

[1] stats     graphics  grDevices utils     datasets  methods   base     

 

other attached packages:

[1] BiocInstaller_1.28.0

 

loaded via a namespace (and not attached):

[1] compiler_3.4.3 tools_3.4.3   

ADD REPLY
2
Entering edit mode
@danielgaffney-14911
Last seen 6.5 years ago

This problem was caused by using an old version of gcc and is solved by updating to a newer version of the compiler. First, you have to install a new version of gcc (or find an updated version that's already on your machine, which is probably the case if you're working on a shared computing resource). In the solution below (there may be other ways of doing it, this worked for me), the updated version of gcc is located in /software/gcc-6.2.0/. In Linux, before you start R, set the following environmental variables:

export CXX=/software/gcc-6.2.0/bin/g++
export CC=/software/gcc-6.2.0/bin/gcc
export LD_LIBRARY_PATH=/software/gcc-6.2.0/lib64:$LD_LIBRARY_PATH

Note - make sure that the path you add to LD_LIBRARY_PATH actually contains the library "libstdc++.so.6". If you have already installed Rhdflib, you'll need to remove it first and reinstall - use remove.packages("Rhdflib"). Once you've done that beachmat should install without an error.

ADD COMMENT
0
Entering edit mode

Have had the same issue with gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4 and R-3.4.3, but the above solution has not worked for me. Can you elaborate on the purpose of CXX, CC and LD_LIBRARY_PATHs, or perhaps look at what I did and see if you catch anything I didn't:

Original error message:

[...]/beachmat.so:
  /home/felix/miniconda3/envs/scR-3.4.3/lib/R/library/beachmat/libs/beachmat.so: undefined symbol: _ZN2H56H5FileC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEjRKNS_17FileCreatPropListERKNS_15FileAccPropListE

I have installed gcc-6 as suggested here; in a nutshell it's this:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install gcc-6
sudo apt install g++-6
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-6    

This seems to have worked, see the following output:

gcc --version
gcc (Ubuntu/Linaro 6.3.0-18ubuntu2~14.04) 6.3.0 20170519

 g++ --version
g++ (Ubuntu/Linaro 6.3.0-18ubuntu2~14.04) 6.3.0 20170519

I then followed through above solution, in my case this was:

export CXX=/usr/bin/g++-6

export CC=/usr/bin/gcc-6

export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/libstdc++.so.6:$LD_LIBRARY_PATH

In R then:

remove.packages("Rhdf5lib")

biocLite("Rhdf5lib") # installs without problems

biocLite("beachmat")
This again fails with the known error:
Error: package or namespace load failed for ‘beachmat’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/home/felix/miniconda3/envs/scR-3.4.3/lib/R/library/beachmat/libs/beachmat.so':
  /home/felix/miniconda3/envs/scR-3.4.3/lib/R/library/beachmat/libs/beachmat.so: undefined symbol: _ZN2H56H5FileC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEjRKNS_17FileCreatPropListERKNS_15FileAccPropListE

 

 

It is noteworthy that it might also be that it's somehow an issue with my R installation: I am using miniconda to create a separate conda environment to make it go along my system's R-3.4.2.



And finally a note on the above solution: remove.packages("Rhdflib") should be remove.packages("Rhdf5lib")

 

 

 

 

ADD REPLY
0
Entering edit mode

I assume you have also looked at error when installing beachmat, which discusses this issue in some detail. The standard solution is to re-install the packages that beachmat depends on; Rhdf5lib and Rcpp are most important here, as these are necessary for compilation. I see that you've already tried that, but make sure you didn't have Rhdf5lib already loaded in the R session (i.e., restart your R session and run biocLite(c("Rhdf5lib", "beachmat")).

ADD REPLY
0
Entering edit mode
Aaron Lun ★ 28k
@alun
Last seen 2 hours ago
The city by the bay

Well, this is a new one. The likely cause of your problem is that your version of GCC doesn't have full support for the C++11 standard, which is necessary for template aliasing via the using keyword.

The solution is simple; update your GCC version, which should not be too hard if you're already using a Linux machine. As the name suggests, C++11 has been around for a while now - almost 7 years, which is an eternity relative to Bioconductor release cycles - so I felt that it was pretty reasonable to expect user-side support for it.

ADD COMMENT
0
Entering edit mode
@danielgaffney-14911
Last seen 6.5 years ago

I've also tried changing various environmental variables :PATH, LD_LIBRARY_PATH, CC and CXX to point to the correct gcc version, so I get:

echo $LD_LIBRARY_PATH;echo $CC; echo $CXX

/software/gcc-6.2.0/lib64/:/usr/local/lsf/9.1/linux2.6-glibc2.3-x86_64/lib:/nfs/users/nfs_d/dg13/local/lib
/software/gcc-6.2.0/bin/gcc
/software/gcc-6.2.0/bin/g++

and
gcc --version
gcc (GCC) 6.2.0

But it either fails with the same error in the pastebin comment above, or with the following:

** testing if installed package can be loaded

Error: package or namespace load failed for ‘beachmat’ in dyn.load(file, DLLpath = DLLpath, ...):

unable to load shared object '/nfs/teams/team170/Daniel/local/lib/R-3.4/library/beachmat/libs/beachmat.so':

  /nfs/teams/team170/Daniel/local/lib/R-3.4/library/beachmat/libs/beachmat.so: undefined symbol: _ZN2H56H5FileC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEjRKNS_17FileCreatPropListERKNS_15FileAccPropListE

ADD COMMENT
0
Entering edit mode

Please respond to existing answers with "add comment", unless you're answering your own question.

The second failure message is much more familiar, see error when installing beachmat for a solution. In brief, your newly built beachmat library is trying to link to Rhdf5lib built using your old GCC, so you need to reinstall that.

ADD REPLY
0
Entering edit mode

So I removed and reinstalled Rhdf5lib as follows:
source("https://bioconductor.org/biocLite.R")
remove.packages("Rhdf5lib")
biocLite("Rhdf5lib")

This works fine, now I get the following error when installing beachmat:
 

Error: package or namespace load failed for ‘beachmat’ in dyn.load(file, DLLpath = DLLpath, ...):

unable to load shared object '/nfs/teams/team170/Daniel/local/lib/R-3.4/library/beachmat/libs/beachmat.so':

  /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /nfs/teams/team170/Daniel/local/lib/R-3.4/library/beachmat/libs/beachmat.so)

Error: loading failed

Execution halted

ERROR: loading failed

ADD REPLY
0
Entering edit mode

My guess is that the loader is still using the old libstdc++ (the 6 on the end has nothing to do with GCC 6, see https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html). I can't say that I've run into this before; Dr Google suggests modifying LD_LIBRARY_PATH, but it seems you've already done that. The only advice I can give is anecdotal; when I built GCC 6 on my institute's cluster, I rebuilt R itself, with the following ./configure:

./configure CPPFLAGS="-isystem/lustre/jmlab/software/include/" \
        LDFLAGS="-L/lustre/jmlab/software/lib -L/lustre/jmlab/software/lib64 -Wl,-rpath,/lustre/jmlab/software/lib -Wl,-rpath,/lustre/jmlab/software/lib64" \
        F77="gfortran"

... and that seemed to work out. I guess the analogous situation would be to look for lib instead of only lib64?

ADD REPLY
0
Entering edit mode

Thanks again. I rebuilt R-3.4.3 with the following flags:
./configure --prefix=$HOME/local LDFLAGS="-L/software/gcc-6.2.0/lib -L$HOME/local/lib" --disable-openmp
(I had some issues with compiling with openmp enabled, so I switched it off). I had the following env variables set:

echo $LD_LIBRARY_PATH
/software/gcc-6.2.0/lib:/usr/local/lsf/9.1/linux2.6-glibc2.3-x86_64/lib:/nfs/users/nfs_d/dg13/local/lib
echo $CC
/software/gcc-6.2.0/bin/gcc
echo $CXX
/software/gcc-6.2.0/bin/g++

Unfortunately, beachmat install still fails with the same error:
Error: package or namespace load failed for ‘beachmat’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/nfs/teams/team170/Daniel/local/lib/R-3.4/library/beachmat/libs/beachmat.so':
  /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /nfs/teams/team170/Daniel/local/lib/R-3.4/library/beachmat/libs/beachmat.so)

I have no idea why the loader is still trying to use the /usr/lib library - it's an environmental variable that needs to be set, but I don't know what it is. 

 

 

 

ADD REPLY
0
Entering edit mode

I wonder what happens when you look at the beachmat shared library. Try cloning from https://github.com/LTLA/beachmat (use the RELEASE_3_6 branch); run R CMD INSTALL beachmat/; enter src and see what ldd beachmat.so gives you. I get the following stuff:

linux-vdso.so.1 =>  (0x00007fffb1dfd000)
libstdc++.so.6 => /lustre/jmlab/software/lib64/libstdc++.so.6 (0x00002ae7e8c0e000)
libm.so.6 => /lib64/libm.so.6 (0x00002ae7e8fcb000)
libgcc_s.so.1 => /lustre/jmlab/software/lib64/libgcc_s.so.1 (0x00002ae7e924e000)
libc.so.6 => /lib64/libc.so.6 (0x00002ae7e9465000)
/lib64/ld-linux-x86-64.so.2 (0x00000037dc000000)

... which indicates that yes, indeed, I am getting the right versions of various GCC-related things. If your beachmat.so is pointing at the wrong thing, it seems like a problem with the linker; try modifying the package Makevars to force your -Wl,rpath's into PKG_LIBS. (I would also make sure that /software/gcc-6.2.0/lib actually contains libstdc++.so.6.)

ADD REPLY
0
Entering edit mode

I think that the paths above are dynamically determined; if they're wrong then LD_LIBRARY_PATH=... ldd beachmat.so might do the right thing, where the path is to the location of the correct libraries.

ADD REPLY
0
Entering edit mode

Solved! Your final point was the key - libstdc++.so.6 is found in lib64 not lib. (Argh). It seems it is sufficient to include the library in LD_LIBRARY_PATH for the compilation to succeed. Thanks again for your help! (I will post the solution as a reply to the main question).

ADD REPLY

Login before adding your answer.

Traffic: 894 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6