genome / joinx

a tool for processing .bed and .vcf files
21 stars 11 forks source link

Build errors on OS X #3

Open sjackman opened 10 years ago

sjackman commented 10 years ago

I attempted to build joinx on OS X. I ran into a few errors. Here's a gist of the complete build log: https://gist.github.com/sjackman/6720321

And a few snippets:

src/lib/common/MutationSpectrum.hpp:3:10: fatal error: 'array' file not found
src/lib/common/CigarString.hpp:3:10: fatal error: 'cstdint' file not found
src/lib/fileformats/Bed.hpp:4:10: fatal error: 'cstdint' file not found
src/lib/fileformats/ChromPos.hpp:4:10: fatal error: 'cstdint' file not found
src/lib/fileformats/InputStream.hpp:23:18: error: no template named 'shared_ptr' in namespace 'std'; did you mean 'boost::shared_ptr'?
src/lib/fileformats/TypedStream.hpp:45:18: error: no template named 'shared_ptr' in namespace 'std'; did you mean 'boost::shared_ptr'?
src/lib/fileformats/Bed.hpp:4:10: fatal error: 'cstdint' file not found
sjackman commented 10 years ago

Here's a link to the Homebrew formula: https://github.com/Homebrew/homebrew-science/blob/joinx/joinx.rb

tabbott commented 10 years ago

Joinx is not generally supported on OS X. This is because it requires C++11 features that are not available in Apple's default compilers. If Homebrew provides a recent version of gcc (4.4+, 4.8 recommended) or clang (3.2+), then you could try that. Be advised that you'd need to make sure that boost is compiled with the same C++ compiler.

sjackman commented 10 years ago

Hi Travis,

Thanks for your quick response. I am using a recent version of clang. https://gist.github.com/sjackman/6720321#file-joinx-log-L18

$ c++ --version
Apple LLVM version 5.0 (clang-500.2.75) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin12.5.0
Thread model: posix

Cheers, Shaun

nnutter commented 10 years ago

I work with Travis. I was trying to get make a formulae for JoinX as well, homebrew-misc/joinx.rb, but was never able to get it to build with clang. I thought about using gcc-4.8 from homebrew-versions but have not had good experiences trying to use multiple compilers with homebrew.

Also, I think you should add depends_on 'samtools' => :build to your formulae.

tabbott commented 10 years ago

The versions reported by the compilers that Apple ships do not always map back to the versions that they are "based on", and I've yet to meet one that supports much of C++11. The errors indicate that this is in fact the problem (missing header, no std::shared_ptr, etc.). What I ended up doing on my mac was building gcc 4.6 as I had bad luck with homebrew installing alternate versions of gcc.

tabbott commented 10 years ago

Hi n! Joinx doesn't depend on samtools. I think it may have at some point in the past for reading fastas, but it doesn't anymore :)

sjackman commented 10 years ago

I see in the build log Set cxxflags to -std=c++0x. Should that be -std=c++11? https://gist.github.com/sjackman/6720321#file-joinx-log-L36

tabbott commented 10 years ago

c++0x should be ok (and it's required by the old gcc we use at TGI). You can try to change it (in the top level CMakeLists.txt) but I don't think it will help. I'll go through and replace some C++11 features with the versions available from boost, but that still may not be enough.

tabbott commented 10 years ago

I just pushed a commit switching to boost for /most/ c++11 features (smart pointers, bind(), cstdint, all/any_of, ...). The code still makes heavy use of C++11's 'auto' keyword, but I think some versions of Apple's compilers support that. I don't have access to one that does, however, so I can't test it myself.

tabbott commented 10 years ago

So it turns out that the compiler actually does support enough of C++11, you just have to tell it to use libc++ instead of libstdc++ (I'm testing with xcode 5 / llvm 3.3, but I imagine the 3.2-based version you have will also work). This causes problems for google test, but there's a compile time flag to fix that too:

export CXXFLAGS="-stdlib=libc++ -DGTEST_USE_OWN_TR1_TUPLE=1"

before running cmake will get you around most of the C++11 things. There are still a few more issues I need to work out (no strverscmp on os x and a few integer size issues with certain template functions), but that shouldn't take forever to fix.