ethereum / aleth

Aleth – Ethereum C++ client, tools and libraries
GNU General Public License v3.0
3.96k stars 2.17k forks source link

macOS Sierra - Build from source failed:Performing build step for 'snark' failed #4267

Closed oushuintern closed 7 years ago

oushuintern commented 7 years ago

I tried many times to build cpp-ethereum from source code and without exception I always met this err message:

system info : macOS Sierra 10.12.5, xcode version 8.3.3

[ 24%] Performing build step for 'snark' [ 12%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/alt_bn128/alt_bn128_g2.cpp.o [ 12%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/alt_bn128/alt_bn128_g1.cpp.o [ 12%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/alt_bn128/alt_bn128_init.cpp.o [ 24%] Building CXX object libdevcore/CMakeFiles/devcore.dir/Base64.cpp.o [ 24%] Building CXX object libdevcore/CMakeFiles/devcore.dir/Common.cpp.o [ 25%] Building CXX object libdevcore/CMakeFiles/devcore.dir/CommonData.cpp.o [ 25%] Building CXX object libdevcore/CMakeFiles/devcore.dir/CommonIO.cpp.o [ 25%] Building CXX object libdevcore/CMakeFiles/devcore.dir/CommonJS.cpp.o [ 26%] Building CXX object libdevcore/CMakeFiles/devcore.dir/FileSystem.cpp.o /usr/local/cppether/cpp-ethereum/deps/src/snark/src/algebra/curves/alt_bn128/alt_bn128_g2.cpp:424:9: fatal error: invalid operands to binary expression ('std::ostream' (aka 'basic_ostream') and 'alt_bn128_Fq2' (aka 'Fp2_model<alt_bn128_q_limbs, alt_bn128_modulus_q>')) out << copy.X << OUTPUT_SEPARATOR << copy.Y;


/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ostream:207:20: note: candidate function not viable: no known conversion from 'alt_bn128_Fq2' (aka 'Fp2_model<alt_bn128_q_limbs, alt_bn128_modulus_q>') to 'const void *' for 1st argument; take the address of the argument with &
    basic_ostream& operator<<(const void* __p);
                   ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ostream:191:20: note: candidate function not viable: no known conversion from 'alt_bn128_Fq2' (aka 'Fp2_model<alt_bn128_q_limbs, alt_bn128_modulus_q>') to 'std::__1::bas/usr/local/cppether/cpp-ethereum/deps/src/snark/src/algebra/curves/alt_bn128/alt_bn128_g1.cpp:411:9: fatal error: invalid operands to binary expression ('std::ostream' (aka 'basic_ostream<char>') and 'alt_bn128_Fq' (aka 'Fp_model<alt_bn128_q_limbs, alt_bn128_modulus_q>'))
    out << copy.X << OUTPUT_SEPARATOR << copy.Y;
    ~~~ ^  ~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ostream:207:20: note: candidate function not viable: no known conversion from 'alt_bn128_Fq' (aka 'Fp_model<alt_bn128_q_limbs, alt_bn128_modulus_q>') to 'const void *' for 1st argument; take the address of the argument with &
    basic_ostream& operator<<(const void* __p);
                   ^

may anyone support me more information to solve this problem?
chfast commented 7 years ago

You have to use clang 4.0+ compiler.

cdetrio commented 7 years ago

Upgrading to clang 4.0:


$ brew upgrade llvm
==> Upgrading 1 outdated package, with result:
llvm 4.0.1
==> Upgrading llvm 
==> Downloading https://homebrew.bintray.com/bottles/llvm-4.0.1.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring llvm-4.0.1.sierra.bottle.tar.gz
==> Using the sandbox
==> Caveats
To use the bundled libc++ please add the following LDFLAGS:
  LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"

This formula is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have this software first in your PATH run:
  echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.bash_profile

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/llvm/lib
    CPPFLAGS: -I/usr/local/opt/llvm/include

If you need Python to find bindings for this keg-only formula, run:
  echo /usr/local/opt/llvm/lib/python2.7/site-packages >> /usr/local/lib/python2.7/site-packages/llvm.pth
==> Summary
🍺  /usr/local/Cellar/llvm/4.0.1: 2,244 files, 1021.3MB

Then to build cpp-ethereum:

$ cmake -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++ -L/usr/local/opt/llvm/lib -I/usr/local/opt/llvm/include ..

------------------------------------------------------------------------
-- Configuring cpp-ethereum
------------------------------------------------------------------------
-- CMake 3.9.0 (/usr/local/Cellar/cmake/3.9.0/bin/cmake)
-- CMAKE_BUILD_TYPE Build type                               
-- TARGET_PLATFORM  Target platform                          Darwin
-- BUILD_SHARED_LIBS                                         OFF
--------------------------------------------------------------- features
--                  Hardware identification support          
-- VMTRACE          VM execution tracing                     OFF
-- PROFILING        Profiling support                        OFF
-- FATDB            Full database exploring                  ON
-- ROCKSDB          Prefer rocksdb to leveldb                OFF
-- PARANOID         -                                        OFF
-- MINIUPNPC        -                                        OFF
------------------------------------------------------------- components
-- TESTS            Build tests                              ON
-- TOOLS            Build tools                              ON
-- EVMJIT           Build LLVM-based JIT EVM                 OFF
------------------------------------------------------------------------

-- Cpuid headers: CPUID_INCLUDE_DIR-NOTFOUND
-- Cpuid lib   : CPUID_LIBRARY-NOTFOUND
-- miniupnpc headers: /usr/local/include
-- miniupnpc lib   : /usr/local/lib/libminiupnpc.dylib
-- test: ClientBase |  --eth_testfile=BlockTests/bcJS_API_Test --eth_threads=1; --eth_testfile=BlockTests/bcJS_API_Test --eth_threads=3; --eth_testfile=BlockTests/bcJS_API_Test --eth_threads=10; --eth_testfile=BlockTests/bcValidBlockTest --eth_threads=1; --eth_testfile=BlockTests/bcValidBlockTest --eth_threads=3; --eth_testfile=BlockTests/bcValidBlockTest --eth_threads=10
-- Configuring done
-- Generating done
-- Build files have been written to: /cpp/cpp-ethereum/build
$ cmake --build .
[  0%] Built target BuildInfo.h
[  3%] Built target boost
[  6%] Built target mpir
[  6%] Performing configure step for 'snark'
-- GMP include dir: /cpp/cpp-ethereum/deps/include
-- Configuring done
-- Generating done
-- Build files have been written to: /cpp/cpp-ethereum/deps/src/snark-build
[  6%] Performing build step for 'snark'
[  4%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/alt_bn128/alt_bn128_g1.cpp.o
[  8%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/alt_bn128/alt_bn128_g2.cpp.o
[ 12%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/alt_bn128/alt_bn128_init.cpp.o
[ 16%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/alt_bn128/alt_bn128_pairing.cpp.o
[ 20%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/alt_bn128/alt_bn128_pp.cpp.o
[ 24%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/edwards/edwards_g1.cpp.o
[ 28%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/edwards/edwards_g2.cpp.o
[ 32%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/edwards/edwards_init.cpp.o
[ 36%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/edwards/edwards_pairing.cpp.o
[ 40%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/edwards/edwards_pp.cpp.o
[ 44%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/mnt/mnt4/mnt4_g1.cpp.o
[ 48%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/mnt/mnt4/mnt4_g2.cpp.o
[ 52%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/mnt/mnt4/mnt4_init.cpp.o
[ 56%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/mnt/mnt4/mnt4_pairing.cpp.o
[ 60%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/mnt/mnt4/mnt4_pp.cpp.o
[ 64%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/mnt/mnt46_common.cpp.o
[ 68%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/mnt/mnt6/mnt6_g1.cpp.o
[ 72%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/mnt/mnt6/mnt6_g2.cpp.o
[ 76%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/mnt/mnt6/mnt6_init.cpp.o
[ 80%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/mnt/mnt6/mnt6_pairing.cpp.o
[ 84%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/mnt/mnt6/mnt6_pp.cpp.o
[ 88%] Building CXX object src/CMakeFiles/ff.dir/common/double.cpp.o
/cpp/cpp-ethereum/deps/src/snark/src/common/double.cpp:22:16: warning: unused variable 'PI' [-Wunused-const-variable]
  const double PI = 3.141592653589793238460264338328L;
               ^
1 warning generated.
[ 92%] Building CXX object src/CMakeFiles/ff.dir/common/profiling.cpp.o
/cpp/cpp-ethereum/deps/src/snark/src/common/profiling.cpp:332:35: warning: unused parameter 's' [-Wunused-parameter]
void print_mem(const std::string &s)
                                  ^
1 warning generated.
[ 96%] Building CXX object src/CMakeFiles/ff.dir/common/utils.cpp.o
[100%] Linking CXX static library libff.a
[100%] Built target ff
[  6%] Performing install step for 'snark'
[100%] Built target ff
Install the project...
-- Install configuration: ""
-- Up-to-date: /cpp/cpp-ethereum/deps/include/libff
-- Installing: /cpp/cpp-ethereum/deps/include/libff/algebra

.....

-- Installing: /cpp/cpp-ethereum/deps/include/libff/common/utils.tcc
-- Installing: /cpp/cpp-ethereum/deps/lib/libff.a
[  6%] Completed 'snark'
[  8%] Built target snark
Scanning dependencies of target secp256k1
[  9%] Creating directories for 'secp256k1'
[  9%] Performing download step (download, verify and extract) for 'secp256k1'
-- Downloading...

.....

[ 96%] Building CXX object test/CMakeFiles/testeth.dir/unittests/libweb3core/memorydb.cpp.o
[ 97%] Building CXX object test/CMakeFiles/testeth.dir/unittests/libweb3core/overlaydb.cpp.o
[ 97%] Building CXX object test/CMakeFiles/testeth.dir/unittests/libweb3jsonrpc/AccountHolder.cpp.o
[ 98%] Building CXX object test/CMakeFiles/testeth.dir/unittests/libweb3jsonrpc/Client.cpp.o
[ 98%] Building CXX object test/CMakeFiles/testeth.dir/unittests/libweb3jsonrpc/jsonrpc.cpp.o
[ 98%] Building CXX object test/CMakeFiles/testeth.dir/unittests/libwhisper/bloomFilter.cpp.o
[ 99%] Building CXX object test/CMakeFiles/testeth.dir/unittests/libwhisper/whisperDB.cpp.o
[ 99%] Building CXX object test/CMakeFiles/testeth.dir/unittests/libwhisper/whisperMessage.cpp.o
[ 99%] Building CXX object test/CMakeFiles/testeth.dir/unittests/libwhisper/whisperTopic.cpp.o
[100%] Linking CXX executable testeth
[100%] Built target testeth