YuLab-SMU / GOSemSim

:golf: GO-terms Semantic Similarity Measures
https://yulab-smu.top/biomedical-knowledge-mining-book/
58 stars 26 forks source link

Compilation error on Linux with GCC 6.1.1 #6

Closed khughitt closed 8 years ago

khughitt commented 8 years ago

Hello,

I've run into some compilation errors recently when trying to install GOSemSim:

> > devtools::install_github('GuangchuangYu/GOSemSim')
> Downloading GitHub repo GuangchuangYu/GOSemSim@master
> from URL https://api.github.com/repos/GuangchuangYu/GOSemSim/zipball/master
> Installing GOSemSim
> '/usr/lib64/R/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL  \
>   '/tmp/Rtmp0h9h7m/devtools125be1a098e/GuangchuangYu-GOSemSim-f5446e3' --library='/home/keith/R/library/3.3'  \
>   --install-tests 
> 
> * installing *source* package ‘GOSemSim’ ...
> ** libs
> g++ -I/usr/include/R/ -DNDEBUG  -D_FORTIFY_SOURCE=2 -I"/home/keith/R/library/3.3/Rcpp/include"   -fpic  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong  -c ICmethod.cpp -o ICmethod.o
> In file included from /usr/include/c++/6.1.1/map:60:0,
>                  from /home/keith/R/library/3.3/Rcpp/include/RcppCommon.h:56,
>                  from /home/keith/R/library/3.3/Rcpp/include/Rcpp.h:27,
>                  from ICmethod.cpp:1:
> /usr/include/c++/6.1.1/bits/stl_tree.h: In instantiation of ‘std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(_Arg&&) [with _Arg = std::pair<Rcpp::internal::string_proxy<16>, double>; _Key = std::__cxx11::basic_string<char>; _Val = std::pair<const std::__cxx11::basic_string<char>, double>; _KeyOfValue = std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, double> >; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, double> >]’:
> /usr/include/c++/6.1.1/bits/stl_map.h:740:64:   required from ‘std::pair<typename std::_Rb_tree<_Key, std::pair<const _Key, _Tp>, std::_Select1st<std::pair<const _Key, _Tp> >, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<std::pair<const _Key, _Tp> >::other>::iterator, bool> std::map<_Key, _Tp, _Compare, _Alloc>::insert(_Pair&&) [with _Pair = std::pair<Rcpp::internal::string_proxy<16>, double>; <template-parameter-2-2> = void; _Key = std::__cxx11::basic_string<char>; _Tp = double; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, double> >; typename std::_Rb_tree<_Key, std::pair<const _Key, _Tp>, std::_Select1st<std::pair<const _Key, _Tp> >, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<std::pair<const _Key, _Tp> >::other>::iterator = std::_Rb_tree_iterator<std::pair<const std::__cxx11::basic_string<char>, double> >]’
> ICmethod.cpp:91:65:   required from here
> /usr/include/c++/6.1.1/bits/stl_tree.h:1859:28: error: no matching function for call to ‘std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, double>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, double> >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, double> > >::_M_get_insert_unique_pos(std::pair<Rcpp::internal::string_proxy<16>, double>::first_type&)’
>   = _M_get_insert_unique_pos(_KeyOfValue()(__v));
>     ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
> /usr/include/c++/6.1.1/bits/stl_tree.h:1796:5: note: candidate: std::pair<std::_Rb_tree_node_base*, std::_Rb_tree_node_base*> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_unique_pos(const key_type&) [with _Key = std::__cxx11::basic_string<char>; _Val = std::pair<const std::__cxx11::basic_string<char>, double>; _KeyOfValue = std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, double> >; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, double> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::key_type = std::__cxx11::basic_string<char>]
>      _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
>      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /usr/include/c++/6.1.1/bits/stl_tree.h:1796:5: note:   no known conversion for argument 1 from ‘std::pair<Rcpp::internal::string_proxy<16>, double>::first_type {aka Rcpp::internal::string_proxy<16>}’ to ‘const key_type& {aka const std::__cxx11::basic_string<char>&}’
> /usr/include/c++/6.1.1/bits/stl_tree.h: In instantiation of ‘std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(_Arg&&) [with _Arg = std::pair<Rcpp::internal::string_proxy<16>, std::set<std::__cxx11::basic_string<char> > >; _Key = std::__cxx11::basic_string<char>; _Val = std::pair<const std::__cxx11::basic_string<char>, std::set<std::__cxx11::basic_string<char> > >; _KeyOfValue = std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, std::set<std::__cxx11::basic_string<char> > > >; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, std::set<std::__cxx11::basic_string<char> > > >]’:
> /usr/include/c++/6.1.1/bits/stl_map.h:740:64:   required from ‘std::pair<typename std::_Rb_tree<_Key, std::pair<const _Key, _Tp>, std::_Select1st<std::pair<const _Key, _Tp> >, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<std::pair<const _Key, _Tp> >::other>::iterator, bool> std::map<_Key, _Tp, _Compare, _Alloc>::insert(_Pair&&) [with _Pair = std::pair<Rcpp::internal::string_proxy<16>, std::set<std::__cxx11::basic_string<char> > >; <template-parameter-2-2> = void; _Key = std::__cxx11::basic_string<char>; _Tp = std::set<std::__cxx11::basic_string<char> >; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, std::set<std::__cxx11::basic_string<char> > > >; typename std::_Rb_tree<_Key, std::pair<const _Key, _Tp>, std::_Select1st<std::pair<const _Key, _Tp> >, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<std::pair<const _Key, _Tp> >::other>::iterator = std::_Rb_tree_iterator<std::pair<const std::__cxx11::basic_string<char>, std::set<std::__cxx11::basic_string<char> > > >]’
> ICmethod.cpp:112:62:   required from here
> /usr/include/c++/6.1.1/bits/stl_tree.h:1859:28: error: no matching function for call to ‘std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, std::set<std::__cxx11::basic_string<char> > >, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, std::set<std::__cxx11::basic_string<char> > > >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, std::set<std::__cxx11::basic_string<char> > > > >::_M_get_insert_unique_pos(std::pair<Rcpp::internal::string_proxy<16>, std::set<std::__cxx11::basic_string<char> > >::first_type&)’
>   = _M_get_insert_unique_pos(_KeyOfValue()(__v));
>     ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
> /usr/include/c++/6.1.1/bits/stl_tree.h:1796:5: note: candidate: std::pair<std::_Rb_tree_node_base*, std::_Rb_tree_node_base*> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_unique_pos(const key_type&) [with _Key = std::__cxx11::basic_string<char>; _Val = std::pair<const std::__cxx11::basic_string<char>, std::set<std::__cxx11::basic_string<char> > >; _KeyOfValue = std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, std::set<std::__cxx11::basic_string<char> > > >; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, std::set<std::__cxx11::basic_string<char> > > >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::key_type = std::__cxx11::basic_string<char>]
>      _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
>      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /usr/include/c++/6.1.1/bits/stl_tree.h:1796:5: note:   no known conversion for argument 1 from ‘std::pair<Rcpp::internal::string_proxy<16>, std::set<std::__cxx11::basic_string<char> > >::first_type {aka Rcpp::internal::string_proxy<16>}’ to ‘const key_type& {aka const std::__cxx11::basic_string<char>&}’
> make: *** [/usr/lib64/R/etc/Makeconf:141: ICmethod.o] Error 1
> ERROR: compilation failed for package ‘GOSemSim’
> * removing ‘/home/keith/R/library/3.3/GOSemSim’
> Error: Command failed (1)
> 

System info:

GuangchuangYu commented 8 years ago

I can compile it on Ubuntu using GCC-5.3.1.

It seems that Rcpp is not compatible with std::map implementation in GCC-6.1.1.

GuangchuangYu commented 8 years ago

@eddelbuettel Can you kindly help?

eddelbuettel commented 8 years ago

You probably have to (re-)compile your whole stack using g++-6 instead of mixing.

We do that within Debian for tests and have had no issues provided alll components are compiled with the same compiler as there are again ABI changes between g++-5 and g++-6.

GuangchuangYu commented 8 years ago

@alyst do you have any idea of this?

alyst commented 8 years ago

@GuangchuangYu I haven't tested it myself (although I can reproduce the bug), but maybe just explicitly converting Rcpp string vector elements into std::string would help, i.e. changing line 91 of ICMethod.cpp into

     normIcMap.insert( std::make_pair( (std::string)icNames[i], cic / mic ) );

The same for line 112.

GuangchuangYu commented 8 years ago

@alyst Thanks. It fixed the issue.

@khughitt Please try re-install it and checkout the vignette. The function calls of the devel branch were changed since I extend the method to support more species (OrgDb object that can be queried via AnnotationHub).

khughitt commented 8 years ago

Works! Thanks for the quick fix, and for pointing me to the vignette. Also pretty excited for the capabilities of AnnotationHub.