I've successfully built Zcash on OS X... Ask me anything!

Ok. Thanks for the advice.

I’m attempting to build zcash using macports gcc5 on OSX and ran into this issue libsnark osx - Pastebin.com while attempting to build libsnark.

Has anyone else run into this?

edit: is this related to clang?

It depends… Might be, find out what is your c++ in that build script scope… e.g. $ which c++

MacBook-Pro:zcash mugatu which c++ /opt/local/bin/c++ MacBook-Pro:zcash mugatu c++ -v
Using built-in specs.
COLLECT_GCC=c++
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin15/5.4.0/lto-wrapper
Target: x86_64-apple-darwin15
Configured with: /opt/local/var/macports/build/_opt_mports_dports_lang_gcc5/gcc5/work/gcc-5.4.0/configure --prefix=/opt/local --build=x86_64-apple-darwin15 --enable-languages=c,c++,objc,obj-c++,lto,fortran,java --libdir=/opt/local/lib/gcc5 --includedir=/opt/local/include/gcc5 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-5 --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-5 --with-gxx-include-dir=/opt/local/include/gcc5/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-isl=/opt/local --enable-stage1-checking --disable-multilib --enable-lto --enable-libstdcxx-time --with-build-config=bootstrap-debug --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --with-pkgversion=ā€˜MacPorts gcc5 5.4.0_0’
Thread model: posix
gcc version 5.4.0 (MacPorts gcc5 5.4.0_0)

ok, I got further by removing ā€˜-march=native -mtune=native’ from the libsnark Makefile, but now I’m running into the following:

src/common/profiling.cpp: In function 'long long int libsnark::get_nsec_cpu_time()': src/common/profiling.cpp:41:10: error: '::clock_gettime' has not been declared if ( ::clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) ) ^~ compilation terminated due to -Wfatal-errors. make[1]: *** [src/common/profiling.o] Error 1

Hello Adam

Please
you could write a step by step guide to build on osx ?
THX

Don’t have enough time… The principle is to build everything separately (so it isn’t that messy) with GCC5. BUT you have to be absolutely sure that you’ve really used GCC not Clang.

I without a step by step guide are not able to compile
:frowning:

hey adam
i am totally clouless in zcash mining - do you know somere i can get instruction or consultent about it?
yoni9091@gmail.com

Don’t use MacPorts, it’s essentially a dead project and will make a mess with latest versions of OSX. Clean up your machine (major pain) then install Homebrew.

ok, I used macports for a few years a few years ago and was familiar with it, which is why I used it. I’ll probably end up doing a fresh install in time for zcash

Could you please explain how you replaced clang with the brew gcc compiler? I presume that you can specify this using options with ā€œmakeā€ and ā€œconfigureā€, but there is no documentation, and it is not immediately obvious how to do this.

2 Likes

Using the brew version of gcc does not solve this problem (or if it does, it creates other problems…). See this issue on github.

This is the exact spot I am now stuck at trying to build with gcc 5 from homebrew :frowning:

If I can just get libsnark to build with Apple’s clang, I think I’ve been able to get past all the other issues I’ve seen here or elsewhere with building with it. I’d REALLY like to know how the mythical clang build the libsnark README mentions was accomplished.

@mugatu and I both just got libsnark to build on OS X with gcc5 from brew, you have to install gnu binutils and use the version of ar that’s in it by prepending ā€œAR=garā€ to your make command line. So a mac build/port is getting closer.

2 Likes

Here is my command line: CC=gcc-6 CPP=cpp-6 CXX=g+±6 HOST=x86_64-apple-darwin15.6.0 AR=gar J=12 zcutil/build.sh

I still fail in the libsnark compilation. How exactly did you guys(@anon47418038 & @mugatu) get libsnark to compile?

…
src/common/profiling.cpp: In function ā€˜long long int libsnark::get_nsec_cpu_time()’:
src/common/profiling.cpp:41:10: error: ā€˜::clock_gettime’ has not been declared
if ( ::clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) )
^~
compilation terminated due to -Wfatal-errors.
make[1]: *** [src/common/profiling.o] Error 1
make: *** [/Users/wclark/Sites/zcash/depends/work/build/x86_64-apple-darwin15.6.0/libsnark/0.1-7648794e724/./.stamp_built] Error 2

The short answer is ā€œa couple/few weeks of heavy workā€, here’s the long one: :slight_smile:

@Mugatu hacked up a modified version of profiling.cpp that builds on Mac (it lacks ::clock_gettime support). Also, I went down the AR=gar path before, and it won’t work, other stuff in the dependencies need the Apple Xcode provided ar, which is actually somewhat normal to use on the Mac platform, regardless of compiler. I forked libsnark to use the Apple ar, too, and use that version to build everything in depends/.

I have various branches in my fork of zcash for mac (using clang right now for libsnark seems to be a lost cause) . I can build all the dependencies and most of the stuff in zcash/src on Mac with gcc from brew, but am hitting some C++ issues because gcc has different defaults on Mac vs linux, and GNU autoconf generates some defaults that aren’t right for building zcash, and I’m working through those now.

But I have that on hold right now as rc2 is gonna reset the testnet, and I need to merge its changes into my current Mac branch in my fork.

1 Like

Oh there’s also the list of all the different brew packages I have installed (or NOT, as some things will interfere or get picked by autoconf to link against when they shouldn’t!)

OK, I successfully compiled libsnark by using @mugatu’s approach.
Now I am stuck because OSX install command does not support the -D option.

Here are the 2 references to install using the -D option:

./depends/packages/googlemock.mk: install -D ./make/gmock-all.o ((package)_staging_dir)(host_prefix)/lib/libgmock.a && \ ./depends/packages/googletest.mk: install -D ./make/gtest.a ((package)_staging_dir)(host_prefix)/lib/libgtest.a && \