Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

htslib not found by cmake #30

Closed
ChristopheLegendre opened this issue Aug 11, 2018 · 12 comments
Closed

htslib not found by cmake #30

ChristopheLegendre opened this issue Aug 11, 2018 · 12 comments
Assignees

Comments

@ChristopheLegendre
Copy link

Hi Daniel and the Octopus' Contributors

Describe the bug
htslib directory is not found by cmake.

Command
Command line to run install octopus:

$ cmake -DBOOST_ROOT=/tmp/boost_1.68 -DHTSLIB_ROOT:PATH=/tmp/htslib-1.4 .. 

Desktop (please complete the following information):

  • OS: Linux CentOS 7.2
  • Version Octopus [obtained by runnign git clone as specified in the Octopus' README]
  • Reference None

Additional context
before running the command mentioned above and get the error below, we installed ALL the requirements in /tmp/ folder, i.e.:
Git 2.18.0
Boost 1.68
htslib 1.4
CMake 3.12.1
gcc 8.2

Actions we performed

part1
Then, we added directories of gcc 8.2. cmake 3.12.1, boost 1.68 and htslib 1.4 to the PATH, the LD_LIBRARY_PATH and LIBRARY_PATH variables.
part2
We also created the env variable as follow:
export HTSLIB_ROOT= /tmp/htslib-1.4
and also
export HTSLIB_DIR= /tmp/htslib-1.4
then we run cmake command as described above. We still got the Error Message below.
part3
We also added the file "HTSlibConfig.cmake" to the /tmp/htslib-1.4 directory.
cmake found that file, but not the requested information that should have been in that file; not knowing what information to add to the file and what CMAKE needs, it did not help fixing the issue

** ERROR Message from cmake**


CMake Error at src/CMakeLists.txt:564 (find_package):
By not providing "FindHTSlib.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "HTSlib", but
CMake did not find one.

Could not find a package configuration file provided by "HTSlib" (requested
version 1.4) with any of the following names:
HTSlibConfig.cmake
htslib-config.cmake
Add the installation prefix of "HTSlib" to CMAKE_PREFIX_PATH or set
"HTSlib_DIR" to a directory containing one of the above files. If "HTSlib"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!


Questions

Could you help us fixing this issue?
Could you provide further information needed to get cmake finding the HTSLIB folder?

Thanks.
Chris

@dancooke
Copy link
Member

Hi Chris,

Could you please conform how htslib was installed?

You only need to specify HTSLIB_ROOT if htslib is in a non-standard location, not HTSLIB_DIR too. Also, if you set the HTSLIB_ROOT environment variable then there's no need to pass this to CMake too. I'd also recommend using the installation script if possible. So, if all dependencies are installed correctly then:

export HTSLIB_ROOT=/tmp/htslib-1.4
scripts/install.py --boost /tmp/boost_1.68

Should work. Note there is no space after the = in the export statement.

I've attached a bash script I wrote to install octopus on our centres CentOS cluster. It loads GCC and Python with module but installs all the other dependencies locally. You may find this helpful to check how to correctly install htslib and set up relevant environment variables.

Cheers,
Dan

bash script to install octopus from scratch
#!/usr/bin/env bash

# Summary: This script is for installing a fresh instance of the variant caller Octopus
#          on the Wellcome Centres rescomp cluster.

# Author: Daniel Cooke (dcooke@well.ox.ac.uk)
# Date: 23/06/2018

##############################################
################# Config #####################
##############################################

# Dependency installation directory
DEPENDENCY_DIR=$(pwd)/local

# Dependency versions
GCC_VERSION=7.2.0
CMAKE_VERSION=3.11.4
BOOST_VERSION=1.67.0
HTSLIB_VERSION=master
PYTHON_VERSION=3.4.3

# Octopus version (Github branch or tag)
OCTOPUS_VERSION=master

# Number of threads for compiling
N_THREADS=4

##############################################
##############################################

echo "Loading available modules"
module load gcc/$GCC_VERSION
module load python/$PYTHON_VERSION

mkdir $DEPENDENCY_DIR

echo "Installing CMake ${CMAKE_VERSION}"
CMAKE_DIR=cmake-$CMAKE_VERSION
CMAKE_TAR=${CMAKE_DIR}.tar.gz
CMAKE_MAJOR_VERSION="${CMAKE_VERSION%.*}"
wget https://cmake.org/files/v${CMAKE_MAJOR_VERSION}/${CMAKE_TAR}
tar -xzvf $CMAKE_TAR
rm $CMAKE_TAR
cd $CMAKE_DIR
./bootstrap --prefix=$DEPENDENCY_DIR && make -j$N_THREADS && make install
cd ..
rm -rf $CMAKE_DIR

echo "Installing Boost ${BOOST_VERSION}"
BOOST_VERSION_=${BOOST_VERSION//[.]/_}
BOOST_DIR=boost_$BOOST_VERSION_
BOOST_TAR=${BOOST_DIR}.tar.gz
wget -O $BOOST_TAR http://sourceforge.net/projects/boost/files/boost/${BOOST_VERSION}/${BOOST_TAR}/download
tar -xzvf $BOOST_TAR
rm $BOOST_TAR
cd $BOOST_DIR
./bootstrap.sh --prefix=$DEPENDENCY_DIR --without-libraries=python,mpi
./b2 -j$N_THREADS cxxflags="-std=c++11"
./b2 install
cd ..
rm -rf $BOOST_DIR

echo "Installing htslib"
HTSLIB_DIR=htslib
git clone -b $HTSLIB_VERSION https://github.com/samtools/htslib.git
cd $HTSLIB_DIR
autoheader
autoconf
./configure --prefix=$DEPENDENCY_DIR
make -j$N_THREADS && make install
cd ..
rm -rf $HTSLIB_DIR

# Setup PATH
INCLUDE_PATH=$DEPENDENCY_DIR/include
CMAKE_PATH=$DEPENDENCY_DIR/bin
export PATH=$PATH:$INCLUDE_PATH:$CMAKE_PATH
export HTSLIB_ROOT=$DEPENDENCY_DIR

echo "Installing Octopus"
git clone -b $OCTOPUS_VERSION https://github.com/luntergroup/octopus.git
cd octopus
./scripts/install.py --boost $DEPENDENCY_DIR --threads $N_THREADS
cd ..

# Setup LD libraries
LIB_PATH=$DEPENDENCY_DIR/lib
export LD_LIBRARY_PATH=$LIB_PATH
# Add octopus to PATH
OCTOPUS_BIN_DIR=$(pwd)/octopus/bin
export PATH=$PATH:OCTOPUS_BIN_DIR
# Test installation
octopus --version

# Post installation instructions
LD_LIBRARY_EXPORT_CMD="export LD_LIBRARY_PATH=$LIB_PATH"
ADD_LD_LIBRARY_TO_BASHRC_CMD="echo '$LD_LIBRARY_EXPORT_CMD' >> ~/.bashrc"
echo "You may need to add linked libraries to LD_LIBRARY_PATH. To do this permanently use:"
echo "    $ADD_LD_LIBRARY_TO_BASHRC_CMD"

PATH_STR='$PATH'
OCTOPUS_BIN_EXPORT_CMD="export PATH=$PATH_STR:$OCTOPUS_BIN_DIR"
ADD_OCTOPUS_BIN_TO_BASHRC_CMD="echo '$OCTOPUS_BIN_EXPORT_CMD' >> ~/.bashrc"
echo "Command to add octopus executable to .bashrc:"
echo "    $ADD_OCTOPUS_BIN_TO_BASHRC_CMD"

@dancooke dancooke self-assigned this Aug 11, 2018
@ChristopheLegendre
Copy link
Author

ChristopheLegendre commented Aug 14, 2018

Hi Dan,

Thanks for your reply and sorry for the delay, I was testing some of the following items:

  1. Htslib was downloaded from official website, (htslib-1.4.tar.bz2), untarred, configure, make and make install.

  2. The space in "export HTSLIB_ROOT= /tmp/htslib-1.4" was just a copy/paste error on my side in github. Originally, there was no space in my variable definition. I unset the HTSLIB_DIR variable, and tried to recompile octopus, but got same error, could not find htslib-1.4.

  3. Then, I cloned the octopus' repository the same way you did in the given script using "master" as the name of the version ; this time, because the file "FindHTSlib.cmake" was present in the octopus/build/cmake/modules/ folder, the compilation using cmake found htslib, but errors raised in the "make install".

  4. Therefore, I used the script you provided as is. All went well until the step "octopus' make install" raised errors related to boost and missing parentheses.
    /tmp/local/include/boost/mpl/assert.hpp:188:21: error: unnecessary parentheses in declaration of ‘assert_arg’ [-Werror=parentheses] failed ************ (Pred::************ ^ /tmp/local/include/boost/mpl/assert.hpp:193:21: error: unnecessary parentheses in declaration of ‘assert_not_arg’ [-Werror=parentheses] failed ************ (boost::mpl::not_<Pred>::************ ^

  5. following item 4 above, I modified your script to use the boost version 1.68.0 instead of 1.67, and my local installation of gcc 8.2.0 that was compiled using the following command:
    ./configure --prefix=/tmp/gcc-8.2.0/ --disable-multilib --enable-bootstrap --enable-threads ; make && make install

My last attempt (item 5 above) still raised errors but reached 73% of the octopus "make install" command as you can see in the attached log file. Looks like issue is with boost.

Maybe it can help to know that in the test item 4 above, lots of error in the "make install" of octopus that were parentheses related. such as:

I thank you for your help to reach the 100% compilation :-)

Addendum
6) I Modified your script to be able to install on the fly the GCC you load as module.
By doing so, and using exactly the same versions for all the programs and tools,
I reached 100% of compilation but got an error on the last line:
[ 99%] Building CXX object src/CMakeFiles/octopus.dir/core/calling_components.cpp.o [ 99%] Building CXX object src/CMakeFiles/octopus.dir/core/octopus.cpp.o [100%] Building CXX object src/CMakeFiles/octopus.dir/timers.cpp.o [100%] Linking CXX executable octopus CMakeFiles/octopus.dir/config/option_parser.cpp.o (symbol from plugin): undefined reference to 'vtable for boost::program_options::abstract_variables_map' collect2: error: ld returned 1 exit status make[2]: *** [src/octopus] Error 1 make[1]: *** [src/CMakeFiles/octopus.dir/all] Error 2 make: *** [all] Error 2 No bin directory found, making one Octopus 'version master' installation FAILED

I thank you for your help to reach the 100% compilation :-)

log.install_octopus_from_scratch.zip

@dancooke
Copy link
Member

Thanks Chris. From attempt 5 it looks like GCC 8 is emitting a warning that previous GCC versions weren't (I hadn't included GCC 8 in my integration tests). There is a new octopus release coming out imminently, I'll make everything works with GCC 8.

@dancooke
Copy link
Member

I've updated the Dockerfile on the develop branch to use GCC 8.1. This is now building and linking successfully. I had to change

./b2 -j2 cxxflags="-std=c++11"

to

./b2 -j2 toolset=gcc-8 cxxflags="-std=c++14"

To get Boost to link.

@ChristopheLegendre
Copy link
Author

ChristopheLegendre commented Aug 15, 2018

Hi Dan,
I did another attempt .
6) I Modified your script to be able to install on the fly the same GCC 7.2.0 you used (not GCC 8 this time)
Therefore I used exactly the same versions for all the programs and tools except python which we have already installed on our system as module.

GCC_VERSION == 7.2.0
CMAKE_VERSION == 3.11.4
BOOST_VERSION == 1.67.0
HTSLIB_VERSION == master
PYTHON_VERSION == 3.6.0
OCTOPUS_VERSION == master

By doing so, I reached 100% of compilation but got an error on the last line


[ 99%] Building CXX object src/CMakeFiles/octopus.dir/core/calling_components.cpp.o
[ 99%] Building CXX object src/CMakeFiles/octopus.dir/core/octopus.cpp.o
[100%] Building CXX object src/CMakeFiles/octopus.dir/timers.cpp.o
[100%] Linking CXX executable octopus `

CMakeFiles/octopus.dir/config/option_parser.cpp.o (symbol from plugin): undefined reference to vtable for boost::program_options::abstract_variables_map'
collect2: error: ld returned 1 exit status
make[2]: *** [src/octopus] Error 1
make[1]: *** [src/CMakeFiles/octopus.dir/all] Error 2
make: *** [all] Error 2
No bin directory found, making one
Octopus 'version master' installation FAILED


Hope it helps with the current version.

I will wait for the coming version of octopus and let you know how it goes.
Thanks
Chris

@dancooke
Copy link
Member

Hi @ChristopheLegendre v0.5.0-beta is now available and should resolve this issue. Please re-open if you have any problems.

@ChristopheLegendre
Copy link
Author

@dancooke

Hi Dan,

I just wanted to let you know that I successfully installed octopus-0.5.0-Beta on CentOS 7.2 using the following Dependencies:

Dependency versions

GCC_VERSION=8.2.0
CURL_VERSION=7.61.0
BOOST_VERSION=1.68.0
CMAKE_VERSION=3.12.2
HTSLIB_VERSION=master
PYTHON_VERSION=3.6.0
# Octopus version (Github branch or tag)
OCTOPUS_VERSION=master

To do install Octopus, I modified the script you provided in this issue (see above), and in particular for compiling boost, as you recommended when using GCC8, I added the line:
./b2 -j2 toolset=gcc-8 cxxflags="-std=c++14

I hope this information will help other Octopus' users for installing the tool.

Let me know if you have questions.

Thanks,
Chris

@KamilSJaron
Copy link

I tried to follow this (I installed loads of things through conda) and I also managed to compile it, but run into some problems during linking...

[100%] Linking CXX executable octopus

/ceph/users/kjaron/.conda/envs/fastK/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: /tmp/octopus.rB73vO.ltrans16.ltrans.o: undefined reference to symbol '_ZNSt15basic_streambufIcSt11char_traitsIcEE8overflowEi@@GLIBCXX_3.4'
/ceph/users/kjaron/.conda/envs/fastK/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: /ceph/users/kjaron/.conda/envs/fastK/lib/libstdc++.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [src/CMakeFiles/octopus.dir/build.make:3571: src/octopus] Error 1
make[1]: *** [CMakeFiles/Makefile2:325: src/CMakeFiles/octopus.dir/all] Error 2
make: *** [Makefile:149: all] Error 2

Is there something obvious I have done wrong / easy fix to it? If not, I will just try to properly install it in a clean env with the versions of stuff you mention here (I realized too late I should be paying attention to them).

@KamilSJaron
Copy link

I tried to redo everything in a clean environment with versions mentioned here or higher, I still installed most of things through conda (all but htslib) but I still run in a similar problem with ltrans.o

/ceph/users/kjaron/.conda/envs/octopus/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: /tmp/octopus.p3bHpr.ltrans123.ltrans.o: in function `boost::recursive_mutex::recursive_mutex() [clone .lto_priv.0]':                                                                                                                    
<artificial>:(.text._ZN5boost15recursive_mutexC2Ev.lto_priv.0+0x9a): undefined reference to `boost::system::detail::generic_category_instance'                                     
/ceph/users/kjaron/.conda/envs/octopus/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: <artificial>:(.text._ZN5boost15recursive_mutexC2Ev.lto_priv.0+0x107): undefined reference to `boost::system::detail::generic_category_instance'                                                                                         
/ceph/users/kjaron/.conda/envs/octopus/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: <artificial>:(.text._ZN5boost15recursive_mutexC2Ev.lto_priv.0+0x171): undefined reference to `boost::system::detail::generic_category_instance'                                                                                         
/ceph/users/kjaron/.conda/envs/octopus/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: /tmp/octopus.p3bHpr.ltrans124.ltrans.o: in function `octopus::options::create_temp_file_directory(boost::program_options::variables_map const&)':                                                                                       
<artificial>:(.text._ZN7octopus7options26create_temp_file_directoryERKN5boost15program_options13variables_mapE+0x112): undefined reference to `boost::system::detail::system_category_instance'                                                                                                                                                                       
/ceph/users/kjaron/.conda/envs/octopus/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: <artificial>:(.text._ZN7octopus7options26create_temp_file_directoryERKN5boost15program_options13variables_mapE+0x165): undefined reference to `boost::system::detail::generic_category_instance'                                        
/ceph/users/kjaron/.conda/envs/octopus/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: /tmp/octopus.p3bHpr.ltrans127.ltrans.o: in function `boost::system::error_category::std_category::equivalent(std::error_code const&, int) const':                                                                                       
<artificial>:(.text._ZNK5boost6system14error_category12std_category10equivalentERKSt10error_codei+0x41): undefined reference to `boost::system::detail::generic_category_instance' 
/ceph/users/kjaron/.conda/envs/octopus/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: <artificial>:(.text._ZNK5boost6system14error_category12std_category10equivalentERKSt10error_codei+0x64): undefined reference to `boost::system::detail::generic_category_instance'                                                      
/ceph/users/kjaron/.conda/envs/octopus/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: <artificial>:(.text._ZNK5boost6system14error_category12std_category10equivalentERKSt10error_codei+0xf3): undefined reference to `boost::system::detail::generic_category_instance'                                                      
/ceph/users/kjaron/.conda/envs/octopus/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: /tmp/octopus.p3bHpr.ltrans127.ltrans.o: in function `boost::system::error_category::std_category::equivalent(int, std::error_condition const&) const':                                                                                  
<artificial>:(.text._ZNK5boost6system14error_category12std_category10equivalentEiRKSt15error_condition+0x3b): undefined reference to `boost::system::detail::generic_category_instance'                                                                                                                                                                               
collect2: error: ld returned 1 exit status                                                                                                                                         
make[2]: *** [src/CMakeFiles/octopus.dir/build.make:3552: src/octopus] Error 1                                                                                                     
make[1]: *** [CMakeFiles/Makefile2:340: src/CMakeFiles/octopus.dir/all] Error 2                                                                                                    
make: *** [Makefile:130: all] Error 2      

@dancooke
Copy link
Member

@KamilSJaron What are your installation commands (step-by-step)?

@KamilSJaron
Copy link

KamilSJaron commented Jun 12, 2021

Hi @dancooke, sorry about the mess and thanks tons for looking to it.

I extracted from the history things I did (cleaning the part that did not result in anything useful). Some of the conda commands are replacing the previous ones (at least gcc is installed there 3x).

conda activate octopus

CURL_VERSION=7.61.0
BOOST_VERSION=1.68.0
CMAKE_VERSION=3.12
PYTHON_VERSION=3.6
HTSLIB_VERSION=master
OCTOPUS_VERSION=master

N_THREADS=4

conda install -c anaconda cmake=$CMAKE_VERSION
conda install -c conda-forge boost=$BOOST_VERSION

DEPENDENCY_DIR="/ceph/users/kjaron/.conda/envs/octopus/dependencies"

mkdir -p $DEPENDENCY_DIR

/ceph/users/kjaron; mkdir -p /scratch/$USER/install
/scratch/kjaron; cd /scratch/$USER/install

/scratch/$USER/install; HTSLIB_DIR=htslib
/scratch/kjaron/install; git clone -b $HTSLIB_VERSION https://github.com/samtools/htslib.git
/scratch/kjaron/install; cd $HTSLIB_DIR
/scratch/kjaron/install/htslib; conda install -c conda-forge autoconf
/scratch/kjaron/install/htslib; conda install -c anaconda make
/scratch/kjaron/install/htslib; autoheader
/scratch/kjaron/install/htslib; autoconf
/scratch/kjaron/install/htslib; git submodule update --init --recursive
/scratch/kjaron/install/htslib; ./configure --prefix=$DEPENDENCY_DIR
/scratch/kjaron/install/htslib; make -j$N_THREADS && make install
/scratch/kjaron/install/htslib; cd ..
/scratch/kjaron/install; rm -rf $HTSLIB_DIR

/scratch/kjaron/install; INCLUDE_PATH=$DEPENDENCY_DIR/include
/scratch/kjaron/install; export PATH=$PATH:$INCLUDE_PATH
/scratch/kjaron/install; export HTSLIB_ROOT=$DEPENDENCY_DIR

/scratch/kjaron/install; git clone -b $OCTOPUS_VERSION https://github.com/luntergroup/octopus.git
/scratch/kjaron/install; cd octopus
/scratch/kjaron/install; conda install -c conda-forge binutils
/scratch/kjaron/install; conda install -c conda-forge distro
/scratch/kjaron/install; conda install -c conda-forge cxx-compiler
/scratch/kjaron/install; conda install -c anaconda gmp
/scratch/kjaron/install/octopus; ./scripts/install.py --boost $DEPENDENCY_DIR --threads $N_THREADS

Here it compiles everything but then crushes during linking. Now that I think about it, the problem might be that I might have updated gcc after I compiled htslib, so perhaps it would be worth getting all conda things installed first and then compile htslib and octopus.

@dancooke
Copy link
Member

@KamilSJaron Please try the following:

$ conda update conda
$ conda create --name octopus
$ conda activate octopus
$ conda install -c conda-forge gcc_linux-64 gxx_linux-64 make cmake distro boost-cpp gmp htslib icu bzip2 xz zlib
$ git clone https://github.com/luntergroup/octopus
$ octopus/scripts/install.py -c x86_64-conda-linux-gnu-gcc -cxx x86_64-conda-linux-gnu-g++ --boost ~/miniconda3/envs/octopus --gmp ~/miniconda3/envs/octopus --htslib ~/miniconda3/envs/octopus
$ octopus/bin/octopus --version

assuming conda is installed into your home directory - change as needed if not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants