eos icon indicating copy to clipboard operation
eos copied to clipboard

eosiocpp compilation error when following hello world contract tutorial is still occurring

Open jchung00 opened this issue 8 years ago • 18 comments

I am running on the dawn-v3.0.0 tag, and I'm following the most recent tutorial: https://github.com/EOSIO/eos/wiki/Tutorial-Getting-Started-With-Contracts I'm using Ubuntu 17.10 Server. The error below occurs when I try to compile hello.cpp and generate the hello.wast file using eosiocpp: jae@hkeos:~/eos-dawn-v3.0.0/eos/build/tools$./eosiocpp -o ../contracts/hello/hello.wast ../contracts/hello/hello.cpp

../contracts/hello/hello.cpp:1:10: fatal error: 'eosiolib/eosio.hpp' file not
      found
#include <eosiolib/eosio.hpp>
         ^~~~~~~~~~~~~~~~~~~~
1 error generated.

I've already tried sudo make install again, but it didn't work. #1439

jchung00 avatar Apr 09 '18 06:04 jchung00

You can do this to set a contract :

cleos set contract eosio build/contracts/hello

Lomect avatar Apr 09 '18 12:04 Lomect

You can go https://eosfans.io/topics/193 to find the answer.

Lomect avatar Apr 09 '18 12:04 Lomect

Error is not on the deployment stage, it's when I try to compile using eosiocpp

jchung00 avatar Apr 10 '18 05:04 jchung00

Hi @jchung00, I had the same problem you are having now. Given that you have done sudo make install and everything seems correct with your installation, try then moving the hello contract code to another folder, out of contracts/. That worked for me. It is always good to keep software installation and workspace separate.

Hope it helps.

droidjavier avatar Apr 11 '18 08:04 droidjavier

Same issue here... any solution?

I'm on OSX High Sierra 10.13.3 -- I ran the ./eosio_build.sh (without sudo)

leordev avatar Apr 12 '18 18:04 leordev

Ok!

I made it work after going to build folder and running sudo make install

Perhaps it's a missing command in the build script or it's running without sudo...

leordev avatar Apr 12 '18 19:04 leordev

Getting the same issue here on ubuntu 17.10 with the latest master. Ran sudo make install in the build folder again, tried moving to a different folder and still getting the error compiling from the skeleton. 2 errors and 5 warnings

eosiocpp -o helloworld.wast helloworld.cpp

In file included from helloworld.cpp:5: In file included from ./helloworld.hpp:5: In file included from /usr/local/include/eosiolib/eosio.hpp:7: In file included from /usr/local/include/eosiolib/action.hpp:7: In file included from /usr/local/include/eosiolib/datastream.hpp:9: In file included from /root/opt/boost_1_66_0/include/boost/container/flat_map.hpp:26: In file included from /root/opt/boost_1_66_0/include/boost/container/new_allocator.hpp:24: /root/opt/boost_1_66_0/include/boost/container/throw_exception.hpp:56:21: warning: address of array 'msg' will always evaluate to 'true' [-Wpointer-bool-conversion] BOOST_ASSERT(!msg); ~^~~ /root/opt/boost_1_66_0/include/boost/assert.hpp:60:36: note: expanded from macro 'BOOST_ASSERT'

define BOOST_ASSERT(expr) assert(expr)

                               ^~~~

/usr/local/include/musl/upstream/include/assert.h:8:28: note: expanded from macro 'assert' #define assert(x) ((void)((x) || (__assert_fail(#x, FILE, LINE, func),0))) ^ In file included from helloworld.cpp:5: In file included from ./helloworld.hpp:5: In file included from /usr/local/include/eosiolib/eosio.hpp:7: In file included from /usr/local/include/eosiolib/action.hpp:7: In file included from /usr/local/include/eosiolib/datastream.hpp:9: In file included from /root/opt/boost_1_66_0/include/boost/container/flat_map.hpp:26: In file included from /root/opt/boost_1_66_0/include/boost/container/new_allocator.hpp:24: /root/opt/boost_1_66_0/include/boost/container/throw_exception.hpp:64:25: warning: address of array 'msg' will always evaluate to 'true' [-Wpointer-bool-conversion] BOOST_ASSERT_MSG(!msg, str); ~^~~ /root/opt/boost_1_66_0/include/boost/assert.hpp:61:46: note: expanded from macro 'BOOST_ASSERT_MSG'

define BOOST_ASSERT_MSG(expr, msg) assert((expr)&&(msg))

                                         ^~~~

/usr/local/include/musl/upstream/include/assert.h:8:28: note: expanded from macro 'assert' #define assert(x) ((void)((x) || (__assert_fail(#x, FILE, LINE, func),0))) ^ In file included from helloworld.cpp:5: In file included from ./helloworld.hpp:5: In file included from /usr/local/include/eosiolib/eosio.hpp:7: In file included from /usr/local/include/eosiolib/action.hpp:7: In file included from /usr/local/include/eosiolib/datastream.hpp:9: In file included from /root/opt/boost_1_66_0/include/boost/container/flat_map.hpp:26: In file included from /root/opt/boost_1_66_0/include/boost/container/new_allocator.hpp:24: /root/opt/boost_1_66_0/include/boost/container/throw_exception.hpp:72:25: warning: address of array 'msg' will always evaluate to 'true' [-Wpointer-bool-conversion] BOOST_ASSERT_MSG(!msg, str); ~^~~ /root/opt/boost_1_66_0/include/boost/assert.hpp:61:46: note: expanded from macro 'BOOST_ASSERT_MSG'

define BOOST_ASSERT_MSG(expr, msg) assert((expr)&&(msg))

                                         ^~~~

/usr/local/include/musl/upstream/include/assert.h:8:28: note: expanded from macro 'assert' #define assert(x) ((void)((x) || (__assert_fail(#x, FILE, LINE, func),0))) ^ In file included from helloworld.cpp:5: In file included from ./helloworld.hpp:5: In file included from /usr/local/include/eosiolib/eosio.hpp:7: In file included from /usr/local/include/eosiolib/action.hpp:7: In file included from /usr/local/include/eosiolib/datastream.hpp:9: In file included from /root/opt/boost_1_66_0/include/boost/container/flat_map.hpp:26: In file included from /root/opt/boost_1_66_0/include/boost/container/new_allocator.hpp:24: /root/opt/boost_1_66_0/include/boost/container/throw_exception.hpp:80:25: warning: address of array 'msg' will always evaluate to 'true' [-Wpointer-bool-conversion] BOOST_ASSERT_MSG(!msg, str); ~^~~ /root/opt/boost_1_66_0/include/boost/assert.hpp:61:46: note: expanded from macro 'BOOST_ASSERT_MSG'

define BOOST_ASSERT_MSG(expr, msg) assert((expr)&&(msg))

                                         ^~~~

/usr/local/include/musl/upstream/include/assert.h:8:28: note: expanded from macro 'assert' #define assert(x) ((void)((x) || (__assert_fail(#x, FILE, LINE, func),0))) ^ In file included from helloworld.cpp:5: In file included from ./helloworld.hpp:5: In file included from /usr/local/include/eosiolib/eosio.hpp:7: In file included from /usr/local/include/eosiolib/action.hpp:7: In file included from /usr/local/include/eosiolib/datastream.hpp:9: In file included from /root/opt/boost_1_66_0/include/boost/container/flat_map.hpp:26: In file included from /root/opt/boost_1_66_0/include/boost/container/new_allocator.hpp:24: /root/opt/boost_1_66_0/include/boost/container/throw_exception.hpp:88:25: warning: address of array 'msg' will always evaluate to 'true' [-Wpointer-bool-conversion] BOOST_ASSERT_MSG(!msg, str); ~^~~ /root/opt/boost_1_66_0/include/boost/assert.hpp:61:46: note: expanded from macro 'BOOST_ASSERT_MSG'

define BOOST_ASSERT_MSG(expr, msg) assert((expr)&&(msg))

                                         ^~~~

/usr/local/include/musl/upstream/include/assert.h:8:28: note: expanded from macro 'assert' #define assert(x) ((void)((x) || (__assert_fail(#x, FILE, LINE, func),0))) ^ helloworld.cpp:15:39: error: no matching conversion for functional-style cast from 'uint64_t' (aka 'unsigned long long') to 'eosio::name' eosio::print( "Hello World: ", eosio::name(code), "->", eosio::name(action), "\n" ); ^~~~~~~~~~~~~~~~ /usr/local/include/eosiolib/types.hpp:75:11: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'uint64_t' (aka 'unsigned long long') to 'const eosio::name' for 1st argument struct name { ^ /usr/local/include/eosiolib/types.hpp:75:11: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'uint64_t' (aka 'unsigned long long') to 'eosio::name' for 1st argument /usr/local/include/eosiolib/types.hpp:75:11: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided helloworld.cpp:15:64: error: no matching conversion for functional-style cast from 'uint64_t' (aka 'unsigned long long') to 'eosio::name' eosio::print( "Hello World: ", eosio::name(code), "->", eosio::name(action), "\n" ); ^~~~~~~~~~~~~~~~~~ /usr/local/include/eosiolib/types.hpp:75:11: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'uint64_t' (aka 'unsigned long long') to 'const eosio::name' for 1st argument struct name { ^ /usr/local/include/eosiolib/types.hpp:75:11: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'uint64_t' (aka 'unsigned long long') to 'eosio::name' for 1st argument /usr/local/include/eosiolib/types.hpp:75:11: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided 5 warnings and 2 errors generated.

wpuricz avatar Apr 12 '18 21:04 wpuricz

It looks like contracts/skeleton/skeleton.cpp was last updated on March 22 (826f241330d531ac09af24ff49ea8656213a99fc) and commit b49eb6477c34cac2d00c2345a6dcd1c0f4e1f3e3 on the 28th removed the eosio::name constructor that took a uint64_t.

banshee avatar Apr 13 '18 04:04 banshee

This happens to me as well on dawn-v3.0.0. OS is ubuntu 16.04.

toonsevrin avatar Apr 14 '18 20:04 toonsevrin

Did anyone figured out the solution to the problem with "5 warnings and 2 errors generated"?

vasa-develop avatar Apr 19 '18 12:04 vasa-develop

@vasa-develop Changing eosio::name(code) to eosio::name{code} and eosio::name(action) to eosio::name{action} in the .cpp file generated should fix the errors. its an issue with the code generated by the skeleton.

wpuricz avatar Apr 19 '18 13:04 wpuricz

Hey guys, sorry I should have commented how I fixed this much earlier.

I ran while in the build folder:

$ sudo su
$ make install
$ su <username>

Then, I compiled again, and everything worked :)

jchung00 avatar Apr 20 '18 09:04 jchung00

@jchung00 doing sudo make install again does not solve it for me.

@javierjmc could you post the command you use after you moved it out to another folder? Thank you.

swswsw avatar Apr 27 '18 08:04 swswsw

@swswsw well assuming you have a terminal on your home directory and eos is installed there:

$ mkdir eos-workspace
$ mv eos/build/contracts/hello/ ~/eos-workspace

Then you can go to eos-workspace/hello/ and compile from there. You can also move the folder through the GUI if you have one.

droidjavier avatar Apr 27 '18 09:04 droidjavier

@javierjmc thanks, but obviously I tried moving it to other folder before, but it didn't work, so I was wondering if you did anything special when you issue the compile command? Like including another folder. If it is g++, we can include path with -I command, but eosiocpp doesn't seem to have that option.

swswsw avatar Apr 27 '18 17:04 swswsw

for build skeleton contract in DAWN 3.0 just replace sting: eosio::print( "Hello World: ", eosio::name(code), "->", eosio::name(action), "\n" ); with: eosio::print( "Hello World: ", eosio::name{code}, "->", eosio::name{action}, "\n" );

tsrman avatar May 07 '18 10:05 tsrman

I got this error too, and I solved it by sudo make install in /build then sudo eosiocpp ..... I guess sudo make install is not required, maybe the libs were installed with root authority by the automated build script. I didn't figure it out at the beginning because I didn't get promoted with a dialog asking for password when running the automated build script. And now I found that's because my current account can access all cmd with root without pwd, lol. good luck.

FYI, ubuntu 16.04, current master branch.

xhyumiracle avatar May 31 '18 06:05 xhyumiracle

mac:

cd build
sudo make install

Then, I compiled again, and everything worked .

Rhain avatar Jun 12 '18 01:06 Rhain