eos icon indicating copy to clipboard operation
eos copied to clipboard

/opt/eosio/bin/eosiocpp: line 42: /opt/wasm/bin/clang: No such file or directory

Open noprom opened this issue 8 years ago • 13 comments

Using the docker images of eos to write the Hello World Contract throws this error:

/opt/eosio/bin/eosiocpp: line 42: /opt/wasm/bin/clang: No such file or directory

Docker images: eosio/eos:dawn3x Error Message:

root@nodeosd:/opt/eosio/bin/data-dir/contracts/hello# ls
hello.cpp
root@nodeosd:/opt/eosio/bin/data-dir/contracts/hello# cat hello.cpp
#include <eosiolib/eosio.hpp>
#include <eosiolib/print.hpp>
using namespace eosio;

class hello : public eosio::contract {
  public:
    using contract::contract
    /// @abi action
    void hi( account_name user ) {
      print( "Hello, ", name{user} )
    }
};
EOSIO_ABI( hello, (hi) )
root@nodeosd:/opt/eosio/bin/data-dir/contracts/hello# /opt/eosio/bin/eosiocpp -o hello.wast hello.cpp
/opt/eosio/bin/eosiocpp: line 42: /opt/wasm/bin/clang: No such file or directory

Maybe there's some wrong in the Dockerfile.

noprom avatar Apr 18 '18 14:04 noprom

encounter the same problme

loganwu avatar Apr 22 '18 10:04 loganwu

the same

4575759ww avatar Apr 24 '18 02:04 4575759ww

code in eosiocpp: ($PRINT_CMDS; /opt/wasm/bin/clang -emit-llvm -O3 --std=c++14 --target=wasm32 -nostdinc \

and there are only one dir: eosio/ under /opt/.

flyq avatar Apr 26 '18 08:04 flyq

+1

grigio avatar Apr 29 '18 15:04 grigio

see.

stvenyin avatar Apr 29 '18 15:04 stvenyin

I saw the script located at /opt/eosio/bin/eosiocpp and see line42. It says path of clang(/opt/wasm/bin/clang), so I tried to install clang(apt-get install clang) and change clang path (/opt/wasm/bin/clang) to /usr/bin/clang. But after this, eosiocpp can not find path and print 'hello.cpp:1:10: fatal error: 'eosiolib/eosio.hpp' file not found'

bmy4415 avatar May 01 '18 13:05 bmy4415

@bmy4415 me too #2320 , i think eosiocpp needs to be run inside the exact contract directory of the repo because the paths are relative and the missing file is https://github.com/EOSIO/eos/blob/master/contracts/eosiolib/eosio.hpp

grigio avatar May 01 '18 15:05 grigio

+1

cipherzzz avatar May 02 '18 12:05 cipherzzz

My crude attempt to get this working was to amend the Dockerfile by adding:

COPY --from=builder /opt/wasm /opt/wasm
COPY --from=builder /eos/contracts/eosiolib /usr/lib/include/eosiolib
ENV CPATH $CPATH:/opt/wasm/lib/clang/4.0.1/include

The last line is because:

# find / -name stdint.h 
/opt/wasm/lib/clang/4.0.1/include/stdint.h

However now I receive

/usr/local/include/eosiolib/types.h:8:10: fatal error: 'wchar.h' file not found
#include <wchar.h>
         ^~~~~~~~~

And:

# find / -name wchar.h

discovers nothing

Jarreddebeer avatar May 02 '18 18:05 Jarreddebeer

@Jarreddebeer I thinks it's related to this https://github.com/EOSIO/eos/issues/2335#issuecomment-380621802 Can you post your entire Dockerfile?

grigio avatar May 02 '18 22:05 grigio

Sure, my Dockerfile is the same as the repository's Dockerfile apart from those 3 lines.

I experience the same issue as the OP and the others with: /opt/eosio/bin/eosiocpp: line 42: /opt/wasm/bin/clang: No such file or directory and the line COPY --from=builder /opt/wasm /opt/wasm appears to mitigate that.

Then I experience #2320 compiling from the /contracts folder, the line COPY --from=builder /eos/contracts/eosiolib /usr/lib/include/eosiolib "appears" to mitigate that.

But then stdint.h cannot be found, so I found it and hackily tried to add it to the CPATH environment variable so it would be picked up: ENV CPATH $CPATH:/opt/wasm/lib/clang/4.0.1/include

However, now the wchar.h is missing similarly to #2335, but in this case i've built from the git repo (Dockerfile). It's clear to me there must be a proper way to amend the Dockerfile rather than what i've done.

For completeness, my Dockerfile:

FROM eosio/builder as builder

RUN git clone -b master --depth 1 https://github.com/EOSIO/eos.git --recursive \
    && cd eos \
    && cmake -H. -B"/tmp/build" -GNinja -DCMAKE_BUILD_TYPE=Release -DWASM_ROOT=/opt/wasm -DCMAKE_CXX_COMPILER=clang++ \
       -DCMAKE_C_COMPILER=clang -DCMAKE_INSTALL_PREFIX=/tmp/build  -DSecp256k1_ROOT_DIR=/usr/local -DBUILD_MONGO_DB_PLUGIN=true \
    && cmake --build /tmp/build --target install


FROM ubuntu:16.04

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install openssl && rm -rf /var/lib/apt/lists/*
COPY --from=builder /usr/local/lib/* /usr/local/lib/
COPY --from=builder /tmp/build/bin /opt/eosio/bin
COPY --from=builder /tmp/build/contracts /contracts
COPY --from=builder /eos/Docker/config.ini /
COPY --from=builder /opt/wasm /opt/wasm
COPY --from=builder /eos/contracts/eosiolib /usr/lib/include/eosiolib
COPY nodeosd.sh /opt/eosio/bin/nodeosd.sh
ENV EOSIO_ROOT=/opt/eosio
RUN chmod +x /opt/eosio/bin/nodeosd.sh
ENV LD_LIBRARY_PATH /usr/local/lib
VOLUME /opt/eosio/bin/data-dir
ENV PATH /opt/eosio/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV CPATH $CPATH:/opt/wasm/lib/clang/4.0.1/include

Jarreddebeer avatar May 03 '18 17:05 Jarreddebeer

eosio/builder:latest now has all the required tools/libraries to compile contracts. I just tested using the hello contract. If you run into any other problems, please feel free to open additional issues.

ericiles avatar May 07 '18 17:05 ericiles

My solution for the err: https://github.com/EOSIO/eos/issues/4105#issuecomment-400929571

luckyyang avatar Jun 28 '18 06:06 luckyyang