dnbaker / dashing

Fast and accurate genomic distances using HyperLogLog
GNU General Public License v3.0
160 stars 11 forks source link

Can't build dashing on mac (fatal error: string.h: No such file or directory) #4

Closed karel-brinda closed 5 years ago

karel-brinda commented 5 years ago

I didn't find a way how to compile dashing on mac. Would it be please possible to add an install section to the readme with more details for individual platforms (including dependencies)?

Some of the dependencies require openmp which is not supported by clang. Therefore, one needs to use gcc. However, it seems that gcc (installed using brew) then can't see certain header files.

gcc 4.9

$ make CXX=c++-4.9 CC=gcc-4.9 V=1
git submodule update --init --remote --recursive . && cd bonsai && git checkout master && git pull && make update && \
    cd linear && git checkout master && git pull && cd .. && cd .. && cd distmat && git checkout master && git pull && cd ..

...

cd bonsai/bonsai && make libzstd.a && cp libzstd.a ../../
cd ../zstd && /Applications/Xcode.app/Contents/Developer/usr/bin/make && mv lib/libzstd.a ../bonsai && cd ../bonsai
gcc-4.9 -O3   -I. -I./common -DXXH_NAMESPACE=ZSTD_ -I./legacy -DZSTD_LEGACY_SUPPORT=5  -c -o common/entropy_common.o common/entropy_common.c
In file included from common/entropy_common.c:38:0:
common/mem.h:22:37: fatal error: string.h: No such file or directory
 #include <string.h>     /* memcpy */
                                     ^
compilation terminated.
make[3]: *** [common/entropy_common.o] Error 1
make[2]: *** [lib-release] Error 2
make[1]: *** [libzstd.a] Error 2
make: *** [libzstd.a] Error 2

gcc 5

$ make CXX=c++-5 CC=gcc-5 V=1
git submodule update --init --remote --recursive . && cd bonsai && git checkout master && git pull && make update && \
    cd linear && git checkout master && git pull && cd .. && cd .. && cd distmat && git checkout master && git pull && cd ..

...

cd bonsai/bonsai && make libzstd.a && cp libzstd.a ../../
cd ../zstd && /Applications/Xcode.app/Contents/Developer/usr/bin/make && mv lib/libzstd.a ../bonsai && cd ../bonsai
gcc-5 -O3   -I. -I./common -DXXH_NAMESPACE=ZSTD_ -I./legacy -DZSTD_LEGACY_SUPPORT=5  -c -o common/entropy_common.o common/entropy_common.c
In file included from common/entropy_common.c:38:0:
common/mem.h:22:37: fatal error: string.h: No such file or directory
compilation terminated.
make[3]: *** [common/entropy_common.o] Error 1
make[2]: *** [lib-release] Error 2
make[1]: *** [libzstd.a] Error 2
make: *** [libzstd.a] Error 2
dnbaker commented 5 years ago

Hi, and thanks for making an issue!

Dashing uses relatively modern C++; I'm sorry for the installation difficulty. It's currently tested on gcc[6-9] now that we've rolled back features to be C++14-compliant.

However, on OSX, this should actually be pretty easy. I personally use Homebrew's gcc-8 (https://formulae.brew.sh/formula/gcc), which installed after brew install gcc.

Output from gcc --version

gcc-8 (Homebrew GCC 8.2.0) 8.2.0
Copyright (C) 2018 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.

I hope this helps, and please don't hesitate to ask further. Thanks!

karel-brinda commented 5 years ago

It seems that I managed to make it work with gcc-8 (not with gcc-7 though). Btw. on my system, I have

 gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Seems that brew doesn't create the gcc link on my system (only gcc-8, gcc-5, etc).