grenaud / leeHom

Bayesian reconstruction of ancient DNA fragments
GNU General Public License v3.0
24 stars 14 forks source link

Compile error for master branch on Ubuntu Linux #17

Closed nylander closed 1 month ago

nylander commented 6 months ago

Hi, I'm failing to compile the code (Error) following git clone and make for the master branch. From the output (below), it looks like bamtools is the culprit? How does your current setup look like in order to make the compilation work? Thanks Johan

    $ lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description:    Ubuntu 22.04.4 LTS
    Release:    22.04
    Codename:   jammy

    $ g++ -v
    Using built-in specs.
    COLLECT_GCC=g++
    COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper
    OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
    OFFLOAD_TARGET_DEFAULT=1
    Target: x86_64-linux-gnu
    Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.4.0-1ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-11-XeT9lY/gcc-11-11.4.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-XeT9lY/gcc-11-11.4.0/debian/tmp-gcn/usr --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
    Thread model: posix
    Supported LTO compression algorithms: zlib zstd
    gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04) 

    $ cmake --version
    cmake version 3.22.1

    $ ldd --version
    ldd (Ubuntu GLIBC 2.35-0ubuntu3.6) 2.35
    Copyright (C) 2022 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    Written by Roland McGrath and Ulrich Drepper.

    $ make
    make  CXX="g++"   -C src
    make[1]: Entering directory '/home/nylander/src/leeHom/src'
    cd ../bamtools/ &&  mkdir -p build/  && cd build/ && if cmake ..; then echo ""; else if cmake3 ..; then echo ""; else echo "cmake failed, please install cmake v3"; fi  fi  && make && cd ../..
    CMake Deprecation Warning at CMakeLists.txt:20 (cmake_policy):
      The OLD behavior for policy CMP0042 will be removed from a future version
      of CMake.

      The cmake-policies(7) manual explains that the OLD behaviors of all
      policies are deprecated and that a policy should be set to OLD only under
      specific short-term circumstances.  Projects should be ported to the NEW
      behavior and not rely on setting a policy to OLD.

    -- Checking for one of the modules 'jsoncpp>=1'
    Did NOT find system JsonCpp, instead using bundled version
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /home/nylander/src/leeHom/bamtools/build

    make[2]: Entering directory '/home/nylander/src/leeHom/bamtools/build'
    make[3]: Entering directory '/home/nylander/src/leeHom/bamtools/build'
    make[4]: Entering directory '/home/nylander/src/leeHom/bamtools/build'
    make[4]: Leaving directory '/home/nylander/src/leeHom/bamtools/build'
    make[4]: Entering directory '/home/nylander/src/leeHom/bamtools/build'
    make[4]: Leaving directory '/home/nylander/src/leeHom/bamtools/build'
    [  0%] Built target SharedHeaders
    make[4]: Entering directory '/home/nylander/src/leeHom/bamtools/build'
    Consolidate compiler generated dependencies of target BamTools
    make[4]: Leaving directory '/home/nylander/src/leeHom/bamtools/build'
    make[4]: Entering directory '/home/nylander/src/leeHom/bamtools/build'
    [  1%] Building CXX object src/api/CMakeFiles/BamTools.dir/internal/bam/BamMultiReader_p.cpp.o
    In file included from /usr/include/c++/11/map:60,
                     from /home/nylander/src/leeHom/bamtools/src/api/BamMultiReader.h:13,
                     from /home/nylander/src/leeHom/bamtools/src/api/internal/bam/BamMultiReader_p.h:25,
                     from /home/nylander/src/leeHom/bamtools/src/api/internal/bam/BamMultiReader_p.cpp:10:
    /usr/include/c++/11/bits/stl_tree.h: In instantiation of ‘static const _Key& std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_S_key(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type) [with _Key = BamTools::Internal::MergeItem; _Val = BamTools::Internal::MergeItem; _KeyOfValue = std::_Identity<BamTools::Internal::MergeItem>; _Compare = BamTools::Internal::MergeItemSorter<BamTools::Algorithms::Sort::ByName>; _Alloc = std::allocator<BamTools::Internal::MergeItem>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type = const std::_Rb_tree_node<BamTools::Internal::MergeItem>*]’:
    /usr/include/c++/11/bits/stl_tree.h:2102:44:   required from ‘std::pair<std::_Rb_tree_node_base*, std::_Rb_tree_node_base*> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_equal_pos(const key_type&) [with _Key = BamTools::Internal::MergeItem; _Val = BamTools::Internal::MergeItem; _KeyOfValue = std::_Identity<BamTools::Internal::MergeItem>; _Compare = BamTools::Internal::MergeItemSorter<BamTools::Algorithms::Sort::ByName>; _Alloc = std::allocator<BamTools::Internal::MergeItem>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::key_type = BamTools::Internal::MergeItem]’
    /usr/include/c++/11/bits/stl_tree.h:2151:4:   required from ‘std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_equal(_Arg&&) [with _Arg = const BamTools::Internal::MergeItem&; _Key = BamTools::Internal::MergeItem; _Val = BamTools::Internal::MergeItem; _KeyOfValue = std::_Identity<BamTools::Internal::MergeItem>; _Compare = BamTools::Internal::MergeItemSorter<BamTools::Algorithms::Sort::ByName>; _Alloc = std::allocator<BamTools::Internal::MergeItem>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator = std::_Rb_tree<BamTools::Internal::MergeItem, BamTools::Internal::MergeItem, std::_Identity<BamTools::Internal::MergeItem>, BamTools::Internal::MergeItemSorter<BamTools::Algorithms::Sort::ByName>, std::allocator<BamTools::Internal::MergeItem> >::iterator]’
    /usr/include/c++/11/bits/stl_multiset.h:503:36:   required from ‘std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = BamTools::Internal::MergeItem; _Compare = BamTools::Internal::MergeItemSorter<BamTools::Algorithms::Sort::ByName>; _Alloc = std::allocator<BamTools::Internal::MergeItem>; std::multiset<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<BamTools::Internal::MergeItem, BamTools::Internal::MergeItem, std::_Identity<BamTools::Internal::MergeItem>, BamTools::Internal::MergeItemSorter<BamTools::Algorithms::Sort::ByName>, std::allocator<BamTools::Internal::MergeItem> >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::value_type = BamTools::Internal::MergeItem]’
    /home/nylander/src/leeHom/bamtools/src/api/internal/bam/BamMultiMerger_p.h:135:18:   required from ‘void BamTools::Internal::MultiMerger<Compare>::Add(BamTools::Internal::MergeItem) [with Compare = BamTools::Algorithms::Sort::ByName]’
    /home/nylander/src/leeHom/bamtools/src/api/internal/bam/BamMultiMerger_p.h:128:13:   required from here
    /usr/include/c++/11/bits/stl_tree.h:770:15: error: static assertion failed: comparison object must be invocable as const
      770 |               is_invocable_v<const _Compare&, const _Key&, const _Key&>,
          |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/c++/11/bits/stl_tree.h:770:15: note: ‘std::is_invocable_v<const BamTools::Internal::MergeItemSorter<BamTools::Algorithms::Sort::ByName>&, const BamTools::Internal::MergeItem&, const BamTools::Internal::MergeItem&>’ evaluates to false
    /usr/include/c++/11/bits/stl_tree.h: In instantiation of ‘static const _Key& std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_S_key(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type) [with _Key = BamTools::Internal::MergeItem; _Val = BamTools::Internal::MergeItem; _KeyOfValue = std::_Identity<BamTools::Internal::MergeItem>; _Compare = BamTools::Internal::MergeItemSorter<BamTools::Algorithms::Sort::ByPosition>; _Alloc = std::allocator<BamTools::Internal::MergeItem>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type = const std::_Rb_tree_node<BamTools::Internal::MergeItem>*]’:
    /usr/include/c++/11/bits/stl_tree.h:2102:44:   required from ‘std::pair<std::_Rb_tree_node_base*, std::_Rb_tree_node_base*> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_equal_pos(const key_type&) [with _Key = BamTools::Internal::MergeItem; _Val = BamTools::Internal::MergeItem; _KeyOfValue = std::_Identity<BamTools::Internal::MergeItem>; _Compare = BamTools::Internal::MergeItemSorter<BamTools::Algorithms::Sort::ByPosition>; _Alloc = std::allocator<BamTools::Internal::MergeItem>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::key_type = BamTools::Internal::MergeItem]’
    /usr/include/c++/11/bits/stl_tree.h:2151:4:   required from ‘std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_equal(_Arg&&) [with _Arg = const BamTools::Internal::MergeItem&; _Key = BamTools::Internal::MergeItem; _Val = BamTools::Internal::MergeItem; _KeyOfValue = std::_Identity<BamTools::Internal::MergeItem>; _Compare = BamTools::Internal::MergeItemSorter<BamTools::Algorithms::Sort::ByPosition>; _Alloc = std::allocator<BamTools::Internal::MergeItem>; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator = std::_Rb_tree<BamTools::Internal::MergeItem, BamTools::Internal::MergeItem, std::_Identity<BamTools::Internal::MergeItem>, BamTools::Internal::MergeItemSorter<BamTools::Algorithms::Sort::ByPosition>, std::allocator<BamTools::Internal::MergeItem> >::iterator]’
    /usr/include/c++/11/bits/stl_multiset.h:503:36:   required from ‘std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = BamTools::Internal::MergeItem; _Compare = BamTools::Internal::MergeItemSorter<BamTools::Algorithms::Sort::ByPosition>; _Alloc = std::allocator<BamTools::Internal::MergeItem>; std::multiset<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<BamTools::Internal::MergeItem, BamTools::Internal::MergeItem, std::_Identity<BamTools::Internal::MergeItem>, BamTools::Internal::MergeItemSorter<BamTools::Algorithms::Sort::ByPosition>, std::allocator<BamTools::Internal::MergeItem> >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::value_type = BamTools::Internal::MergeItem]’
    /home/nylander/src/leeHom/bamtools/src/api/internal/bam/BamMultiMerger_p.h:135:18:   required from ‘void BamTools::Internal::MultiMerger<Compare>::Add(BamTools::Internal::MergeItem) [with Compare = BamTools::Algorithms::Sort::ByPosition]’
    /home/nylander/src/leeHom/bamtools/src/api/internal/bam/BamMultiMerger_p.h:128:13:   required from here
    /usr/include/c++/11/bits/stl_tree.h:770:15: error: static assertion failed: comparison object must be invocable as const
    /usr/include/c++/11/bits/stl_tree.h:770:15: note: ‘std::is_invocable_v<const BamTools::Internal::MergeItemSorter<BamTools::Algorithms::Sort::ByPosition>&, const BamTools::Internal::MergeItem&, const BamTools::Internal::MergeItem&>’ evaluates to false
    make[4]: *** [src/api/CMakeFiles/BamTools.dir/build.make:244: src/api/CMakeFiles/BamTools.dir/internal/bam/BamMultiReader_p.cpp.o] Error 1
    make[4]: Leaving directory '/home/nylander/src/leeHom/bamtools/build'
    make[3]: *** [CMakeFiles/Makefile2:318: src/api/CMakeFiles/BamTools.dir/all] Error 2
    make[3]: Leaving directory '/home/nylander/src/leeHom/bamtools/build'
    make[2]: *** [Makefile:136: all] Error 2
    make[2]: Leaving directory '/home/nylander/src/leeHom/bamtools/build'
    make[1]: *** [Makefile:85: /home/nylander/src/leeHom/bamtools/build/src/api/libbamtools.a] Error 2
    make[1]: Leaving directory '/home/nylander/src/leeHom/src'
    make: *** [Makefile:43: all] Error 2
grenaud commented 6 months ago

Hi Johan, thank you for the message! This is not what you want to hear but it builds fine on my Ubuntu 20.04 machine. This seems to be a bamtools problem, I wish I could switch to htslib but I do not have a lot of time to code these days. Could you: 1) in the meantime, use the static executable? 2) raise an issue for bamtools, this is their software not leeHom that is causing the issue.

Thanks again and feel free to report back.

nylander commented 6 months ago

Dear @grenaud !

Thank you for the reply. I totally understand. It is the downside of using someone else's tools as submodule: if it breaks, you have to deal with it.

In your case it's a bit complicated. The bamtools code you checked out as a submodule seems to have stopped working with gcc v. > 9 (as of Ubuntu 20.04.) The current bamtools code compiles fine, however (gcc v. 11 on Ubuntu 22.04). So you are left with their (old) pieces...

I tried to update the bamtools submodule but I couldn't make it work with the rest of the code, but patching the old bamtools code solves the compile issues and make test doesn't complain. I haven't had time to put it all together, but as a "proof of concept":

$ docker run -it ubuntu:22.04
# apt update && apt upgrade -y
# apt install -y build-essential pkg-config git cmake zlib1g-dev libjsoncpp-dev
# git clone --recursive https://github.com/nylander/leeHom.git
# cd leeHom
# git checkout bamtools.patch
# bash ./bamtools.patch.sh
# make
# make test

One more thing:

You might want to add (in the Installation section) that in addition to CMake, the user also needs JsonCpp (e.g. apt install libjsoncpp-dev).

Cheers Johan

grenaud commented 6 months ago

thanks a lot, I will mark your email as unread and address it when my workload goes down :-)

graphenn commented 1 month ago

Hi @grenaud

As Johan mentioned, the current version of bamtools that is integrated as a submodule in the repository does not compile successfully with GCC 11 and later versions, which are now widely used in modern Linux distributions.

Version 2.5.2 of bamtools has addressed the GCC 11+ compatibility issue, ensuring that the library can be compiled and used with the latest compilers. However, directly updating the bamtools submodule to version 2.5.2 has resulted in incompatibility issues, specifically with the error:

/bamtools/src/api/api_global.h:13:10: fatal error: api/bamtools_api_export.h: No such file or directory
   13 | #include "api/bamtools_api_export.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~

The tool https://github.com/grenaud/BCL2BAM2FASTQ is also affected by this issue with the bamtools version. Directly upgrading to version 2.5.2 encounters the same problem.

grenaud commented 1 month ago

Hello, I think I fixed it, can you please check? the static executable should be the same.

graphenn commented 1 month ago

Hi @grenaud I have check it with GCC 12 and it is fixed.