odelaneau / shapeit4

Segmented HAPlotype Estimation and Imputation Tool
MIT License
89 stars 17 forks source link

Error in compilation #20

Open Asutu opened 4 years ago

Asutu commented 4 years ago

Hi,

I'm having a bit of a strain to compile SHAPEIT4 and everything I have tried so far always ends up with an error.

The server I'm working on only has GCC 4.9.2 so I installed GCC 7.1.0 in a local directory. I also installed the Boost library with GCC 7.1.0 in a local directory. Both installs seems to have worked properly, at least as far as I can tell...

However, when trying to install SHAPEIT4 I always get an error that looks something like:

# until here everything compiles OK, then on the last rule of the makefile
g++ -std=c++11 -O3 obj/phaser_management.o obj/phaser_finalise.o obj/phaser_parameters.o obj/phaser_initialise.o obj/phaser_algorithm.o obj/variant_map.o obj/genotype_set.o obj/haplotype_set.o obj/haplotype_writer.o obj/genotype_reader2.o obj/graph_writer.o obj/genotype_reader1.o obj/gmap_reader.o obj/haplotype_segment_double.o obj/haplotype_segment_single.o obj/main.o obj/variant.o obj/hmm_parameters.o obj/genotype_sweep.o obj/genotype_mask.o obj/genotype_prune.o obj/genotype_build.o obj/genotype_managment.o obj/compute_job.o obj/pbwt_solver.o obj/builder.o /home/myname/Scratch/Software/libraries/htslib/1.9-GCC7/lib/libhts.a /home/myname/Scratch/Software/libraries/boost/1_67_0-GCC7/lib/libboost_iostreams.a /home/myname/Scratch/Software/libraries/boost/1_67_0-GCC7/lib/libboost_program_options.a -o bin/shapeit4 -lz -lbz2 -lm -lpthread -llzma -lcurl -lcrypto
obj/haplotype_set.o: In function `void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag) [clone .isra.136]':
haplotype_set.cpp:(.text+0x63): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)'
obj/haplotype_set.o: In function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > string_utils::str<double>(double, int) [clone .isra.138] [clone .constprop.503]':
haplotype_set.cpp:(.text+0x381): undefined reference to `VTT for std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >'
# ... a bunch of other undefined reference follow
positional_options.cpp:(.text._ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE14_M_fill_insertEN9__gnu_cxx17__normal_iteratorIPS5_S7_EEmRKS5_[_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE14_M_fill_insertEN9__gnu_cxx17__normal_iteratorIPS5_S7_EEmRKS5_]+0x6cf): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
make: *** [bin/shapeit4] Error 1

I also tried the suggestions in #7, but to no avail. After some googling I found that these errors could be because different libraries were compiled with different compiler versions, but that doesn't seem to be the case here?

ldd libboost_iostreams.so
    linux-vdso.so.1 =>  (0x00007ffe3fb32000)
    librt.so.1 => /lib64/librt.so.1 (0x00007f98d62a8000)
    libz.so.1 => /lib64/libz.so.1 (0x00007f98d6092000)
    libbz2.so.1 => /lib64/libbz2.so.1 (0x00007f98d5e82000)
    liblzma.so.5 => /lib64/liblzma.so.5 (0x00007f98d5c5b000)
    libstdc++.so.6 => /home/myname/Scratch/Software/Compilers/gcc/7.1.0/lib64/libstdc++.so.6 (0x00007f98d58d9000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f98d55d7000)
    libgcc_s.so.1 => /home/myname/Scratch/Software/Compilers/gcc/7.1.0/lib64/libgcc_s.so.1 (0x00007f98d53bf000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f98d51a3000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f98d4de0000)
    /lib64/ld-linux-x86-64.so.2 (0x000055a40c6da000)

Not sure what to do more. Did anyone experienced the same troubles and can share their solutions here?

Many thanks, Pedro

EDIT:

Boost version is 1_67_0.

$ g++ --version
g++ (GCC) 7.1.0
Copyright (C) 2017 Free Software Foundation, Inc.
Asutu commented 4 years ago

OK, I think I could solve this (after one long day...).

I had to do the following before compilation:

$ LD_LIBRARY_PATH=/home/myname/Scratch/Software/Compilers/gcc/7.1.0/lib64:$LD_LIBRARY_PATH
$ LD_LIBRARY_PATH=/home/myname/Scratch/Software/libraries/boost/1_67_0-GCC7/lib:$LD_LIBRARY_PATH
$ export LD_LIBRARY_PATH
$ export LIBRARY_PATH=~/Scratch/Software/Compilers/gcc/7.1.0/lib:$LIBRARY_PATH

It's better to add these variables to the .bash_profile because otherwise the binary cannot link to these libraries in a new session.