Problem building currency example with eoscpp on OSX
I'm following the steps to build the currency contract example using eoscpp, but am getting the following error on OSX:
$ ../../tools/eoscpp -o currency.wast currency.cpp
-emit-llvm -O3 --std=c++14 --target=wasm32 -ffreestanding -nostdlib -fno-threadsafe-statics -fno-rtti -fno-exceptions -I /usr/local/include -I . -c currency.cpp -o /var/folders/fk/0n8fx3k91ls8lh981zzmm2lh0000gn/T/tmp.3JHT8mql/built/currency.cpp
../../tools/eoscpp: line 36: -emit-llvm: command not found
I have set the following env variables: LLVM_DIR, WASM_LLVM_CONFIG and BINARYEN_ROOT
What am I doing wrong? This is on OSX 10.11.6
bosschaert - I had the same problem when I first built EOS on on 10.12.6 (the documented "installable version" in the EOS doc. My problem turn out to be that my xcode, needed to be updated. The LLVM and Boost code (in my case) was not up to par with what was required to built the EOS platform. So, make sure you run the xcode-select --install step.
I tried this but the error remained.
Then I decided to try it on ubuntu 16. I built all prerequisites as described https://github.com/EOSIO/eos#ubuntu on Ubuntu 16.
Then I build the eos tools (eos/tools$ cmake . && make) and run the eoscpp command again but I'm still getting the exact same error:
~/eos/contracts/currency$ ../../tools/eoscpp -o currency.wast currency.cpp
-emit-llvm -O3 --std=c++14 --target=wasm32 -ffreestanding -nostdlib -fno-threadsafe-statics -fno-rtti -fno-exceptions -I /usr/local/include -I . -c currency.cpp -o /tmp/tmp.6puOQb96mi/built/currency.cpp
../../tools/eoscpp: line 36: -emit-llvm: command not found
Hey @bosschaert, it works on my side, I'm on 2cc40a4eed76b797ba1382ab461fe8b6d3f518c4 with OSX 10.12.6
I met the same problem on OSX 10.13.2
Run this command:
eoscpp -o currency.wast currency.cpp
Gets the following output:
-emit-llvm -O3 --std=c++14 --target=wasm32 -ffreestanding -nostdlib -fno-threadsafe-statics -fno-rtti -fno-exceptions -I /usr/local/include -I . -c currency.cpp -o /var/folders/x2/9mjt7vw565b6n059lxlsh3900000gn/T/tmp.r8DXCo69/built/currency.cpp
/usr/local/bin/eoscpp: line 36: -emit-llvm: command not found
I'm also on 2cc40a4 and tried with OSX 10.11.6 and Ubuntu 16.04, but it doesn't work for me. I'm getting the same as @leizongmin ...
It seems that I don't install and set up the WASM COMPILER correctly.
I rebuild the EOS by using the official ./build.sh scripts, it works for me:
# go to eos source directory
cd eos
# full build
./build.sh darwin full
@bosschaert @EcutDavid you can have a try.
I also did a full build like this on ubuntu. The build completes fine, but the eoscpp program still doesn't work as before.
I looked into it a little more and the problem seems to be that the cmake step doesn't properly substitute some variables, such as @WASM_CLANG@ and @WASM_LLVM_LINK@. Basically the eoscpp file as generated from eoscpp.in contains just a space for these variables, which causes the issue.
I guess cmake needs to be configured to properly substitute these.
That's why the total rebuild works, right ./build.sh darwin full?
For some reason that didn't work for me on OSX, but on ubuntu it worked, so I'm closing this issue. Thanks @all for the help!
I had the same problem.
when I run eoscpp -o currency.wast currency.cpp
the console output that:
/usr/local/wasm/bin/clang -emit-llvm -O3 --std=c++14 --target=wasm32 -ffreestanding -nostdlib -fno-threadsafe-statics -fno-rtti -fno-exceptions -I /usr/local/include -I . -c currency.cpp -o /var/folders/k5/by9hfqf541s0tlj1cn5b8qhm0000gn/T/tmp.CEp1zN85/built/currency.cpp
currency.cpp:6:10: fatal error: 'currency/currency.hpp' file not found
#include <currency/currency.hpp> /// defines transfer struct (abi)
^~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
It expects you to run it from the contracts directory (one directory up) and there you'd just run:
eoscpp -o currency/currency.wast currency/currency.cpp
At least that worked for me...
Reference to your opinion,I also get failed
➜ contracts git:(master) eoscpp -o currency/currency.wast currency/currency.cpp
/usr/local/wasm/bin/clang -emit-llvm -O3 --std=c++14 --target=wasm32 -ffreestanding -nostdlib -fno-threadsafe-statics -fno-rtti -fno-exceptions -I /usr/local/include -I currency -c currency/currency.cpp -o /var/folders/k5/by9hfqf541s0tlj1cn5b8qhm0000gn/T/tmp.lRO96UcS/built/currency.cpp
currency/currency.cpp:6:10: fatal error: 'currency/currency.hpp' file not found
#include <currency/currency.hpp> /// defines transfer struct (abi)
^~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
it looks like , can't found 'currency/currency.hpp' file
Actually, I had the same problem. That currency.hpp file is just in the currency directory but the -I switch passed to the compiler is not set to the right directory (-I . would do it).
What I did to get around it was simply create a currency/currency directory and copy the currency/currency.hpp file to that. Then it works...
ok, I ceate a currency/currency directory and copy the currency/currency.hpp file to that, but I found a new error, my god,it shows that
➜ contracts git:(master) ✗ eoscpp -o currency/currency.wast currency/currency.cpp
/usr/local/wasm/bin/clang -emit-llvm -O3 --std=c++14 --target=wasm32 -ffreestanding -nostdlib -fno-threadsafe-statics -fno-rtti -fno-exceptions -I /usr/local/include -I currency -c currency/currency.cpp -o /var/folders/k5/by9hfqf541s0tlj1cn5b8qhm0000gn/T/tmp.gTvA7pHD/built/currency.cpp
In file included from currency/currency.cpp:6:
currency/currency/currency.hpp:6:10: fatal error: 'eoslib/eos.hpp' file not found
#include <eoslib/eos.hpp>
^~~~~~~~~~~~~~~~
1 error generated.
Right, that's a similar problem. In the end I simply edited the build/tools/eoscpp file to add -I . that will solve both problems.
I don't know what is means, where did I add -I . in eoscpp file
can you print your build/tools/eoscpp file content ?
thanks
@xingstarx
I just got the same problem with you.
You can try add -I ./.. on eoscpp file and compile with eoscpp -o currency.wast currency.cpp (inside currency folder)
for example:
${Home}/opt/wasm/bin/clang -emit-llvm -O3 --std=c++14 --target=wasm32 -ffreestanding -nostdlib -fno-threadsafe-statics -fno-rtti -fno-exceptions -I ./.. -I ${EOSIO_INSTALL_DIR}/include -I $filePath -c $file -o $workdir/built/$name
that can help clang's compiler retrivse currency/currency.hpp or eoslib/eos.hpp.
@masato25 thanks, I edit eoscpp file in /usr/local/bin directory, and after run eoscpp -o currency.wast currency.cpp command, it success.
@bosschaert thanks, thanks for your patiently answer
How can this happen? MacBook-Pro-4:contracts nawaz$ eosio-cpp -o hello.wasm hello.cpp --abigen -bash: eosio-cpp: command not found MacBook-Pro-4:contracts nawaz$