odelaneau / shapeit4

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

Not able to install shapeit4 on Mac #15

Open beausoleilmo opened 4 years ago

beausoleilmo commented 4 years ago

I've been trying to install shapeit4 on Mac (macOS Mojave, 10.14.6).

I installed HTSlib and BOOST (using BREW) and found all the files that I needed to put into the makefile.

#HTSLIB LIBRARY 
HTSLIB_INC=/usr/local/Cellar/htslib/1.10.2/include/htslib # was $(HOME)/Tools/htslib-1.9
HTSLIB_LIB=/usr/local/Cellar/htslib/1.10.2/lib/libhts.a # was $(HOME)/Tools/htslib-1.9/libhts.a

#BOOST IOSTREAM & PROGRAM_OPTION LIBRARIES 
BOOST_INC=/usr/local/Cellar/boost/1.72.0/include/boost # was /usr/include
BOOST_LIB_IO=/usr/local/Cellar/boost/1.72.0/lib/libboost_iostreams.a # was /usr/lib/x86_64-linux-gnu/libboost_iostreams.a
BOOST_LIB_PO=/usr/local/Cellar/boost/1.72.0/lib/libboost_program_options.a # was /usr/lib/x86_64-linux-gnu/libboost_program_options.a

I've also modified the CXXFLAG to run without avx2 (since I don't have that option)

#Portable version without avx2 (much slower)
CXXFLAG=-O3
LDFLAG=-O3
sysctl -a | grep AVX
machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX SMX EST TM2 SSSE3 CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC POPCNT AES PCID XSAVE OSXSAVE TSCTMR **AVX1.0** RDRAND F16C

But when I use make, I always get this error:

g++ -std=c++11 -O3 -c src/io/haplotype_writer.cpp -o obj/haplotype_writer.o -Isrc -I/usr/local/Cellar/htslib/1.10.2/include/htslib  -I/usr/local/Cellar/boost/1.72.0/include/boost
In file included from src/io/haplotype_writer.cpp:22:
In file included from src/io/haplotype_writer.h:25:
In file included from src/utils/otools.h:63:
src/utils/string_utils.h:64:26: error: use of undeclared identifier 'setiosflags'; did you mean 'std::setiosflags'?
                if (prec >= 0) { ss << setiosflags( std::ios::fixed ); ss.precision(prec); }
                                       ^~~~~~~~~~~
                                       std::setiosflags
/Library/Developer/CommandLineTools/usr/include/c++/v1/iomanip:125:1: note: 'std::setiosflags' declared here
setiosflags(ios_base::fmtflags __mask)
^
In file included from src/io/haplotype_writer.cpp:22:
In file included from src/io/haplotype_writer.h:25:
In file included from src/utils/otools.h:63:
src/utils/string_utils.h:72:26: error: use of undeclared identifier 'setiosflags'; did you mean 'std::setiosflags'?
                if (prec >= 0) { ss << setiosflags( std::ios::fixed ); ss.precision(prec); }
                                       ^~~~~~~~~~~
                                       std::setiosflags
/Library/Developer/CommandLineTools/usr/include/c++/v1/iomanip:125:1: note: 'std::setiosflags' declared here
setiosflags(ios_base::fmtflags __mask)
^
src/io/haplotype_writer.cpp:86:3: warning: ignoring return value of function declared with 'warn_unused_result' attribute
      [-Wunused-result]
                bcf_write1(fp, hdr, rec);
                ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/htslib/vcf.h:248:33: note: expanded from macro 'bcf_write1'
    #define bcf_write1(fp,h,v)  bcf_write((fp),(h),(v))
                                ^~~~~~~~~ ~~~~~~~~~~~~
src/io/haplotype_writer.cpp:57:2: warning: ignoring return value of function declared with 'warn_unused_result' attribute
      [-Wunused-result]
        bcf_hdr_write(fp, hdr);
        ^~~~~~~~~~~~~ ~~~~~~~
2 warnings and 2 errors generated.
make: *** [obj/haplotype_writer.o] Error 1
eweitz commented 4 years ago

I get the same error while trying to install SHAPEIT4 on macOS Catalina (10.15).

$ make
g++ -std=c++11 -O3 -mavx2 -mfma  -c src/io/haplotype_writer.cpp -o obj/haplotype_writer.o -Isrc -I/usr/local/Cellar/htslib/1.9 -I/usr/local/Cellar/boost/1.72.0
In file included from src/io/haplotype_writer.cpp:22:
In file included from src/io/haplotype_writer.h:25:
In file included from src/utils/otools.h:63:
src/utils/string_utils.h:64:26: error: use of undeclared identifier 'setiosflags'; did you mean 'std::setiosflags'?
                if (prec >= 0) { ss << setiosflags( std::ios::fixed ); ss.precision(prec); }
                                       ^~~~~~~~~~~
                                       std::setiosflags
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iomanip:126:1: note: 'std::setiosflags' declared here
setiosflags(ios_base::fmtflags __mask)
^
In file included from src/io/haplotype_writer.cpp:22:
In file included from src/io/haplotype_writer.h:25:
In file included from src/utils/otools.h:63:
src/utils/string_utils.h:72:26: error: use of undeclared identifier 'setiosflags'; did you mean 'std::setiosflags'?
                if (prec >= 0) { ss << setiosflags( std::ios::fixed ); ss.precision(prec); }
                                       ^~~~~~~~~~~
                                       std::setiosflags
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iomanip:126:1: note: 'std::setiosflags' declared here
setiosflags(ios_base::fmtflags __mask)
^
2 errors generated.
make: *** [obj/haplotype_writer.o] Error 1

I have both HTSlib and Boost installed via Homebrew. Here are my local changes to specify my own paths for those dependencies, as instructed at https://odelaneau.github.io/shapeit4/#installation:

$ git diff
diff --git a/makefile b/makefile
index c0bd9d2..6b3ce78 100644
--- a/makefile
+++ b/makefile
@@ -2,13 +2,18 @@
 CXX=g++ -std=c++11

 #HTSLIB LIBRARY [SPECIFY YOUR OWN PATHS]
-HTSLIB_INC=$(HOME)/Tools/htslib-1.9
-HTSLIB_LIB=$(HOME)/Tools/htslib-1.9/libhts.a
+# HTSLIB_INC=$(HOME)/Tools/htslib-1.9
+# HTSLIB_LIB=$(HOME)/Tools/htslib-1.9/libhts.a
+HTSLIB_INC=/usr/local/Cellar/htslib/1.9
+HTSLIB_LIB=/usr/local/Cellar/htslib/1.9/lib/libhts.a

 #BOOST IOSTREAM & PROGRAM_OPTION LIBRARIES [SPECIFY YOUR OWN PATHS]
-BOOST_INC=/usr/include
-BOOST_LIB_IO=/usr/lib/x86_64-linux-gnu/libboost_iostreams.a
-BOOST_LIB_PO=/usr/lib/x86_64-linux-gnu/libboost_program_options.a
+# BOOST_INC=/usr/include
+# BOOST_LIB_IO=/usr/lib/x86_64-linux-gnu/libboost_iostreams.a
+# BOOST_LIB_PO=/usr/lib/x86_64-linux-gnu/libboost_program_options.a
+BOOST_INC=/usr/local/Cellar/boost/1.72.0
+BOOST_LIB_IO=/usr/local/Cellar/boost/1.72.0/lib/libboost_iostreams.a
+BOOST_LIB_PO=/usr/local/Cellar/boost/1.72.0/lib/libboost_program_options.a

 #HTSLIB LIBRARY [SPECIFY YOUR OWN PATHS]
 #HTSLIB_INC=/software/UHTS/Analysis/samtools/1.4/include

Being able to use SHAPEIT4 on Mac would be convenient!

eweitz commented 4 years ago

I worked around this issue by using this Docker image: https://hub.docker.com/r/cwhelan/shapeit4.

I'd still prefer to be able to build a Mac binary for SHAPEIT4, but this suffices for me in the meantime.

leecbaker commented 4 years ago

If you replace setiosflags with std::setiosflags at those 4 locations, it should compile fine on Mac.