简体   繁体   中英

fatal error: 'boost/uuid/uuid.hpp' file not found

I am trying to include boost UUID libraries in EOS smart contract .

#include <string>
#include <eosio/crypto.hpp>
#include <boost/uuid/uuid.hpp>

I followed this link to install boost just changed the version to 1.73.0: http://janisz.github.io/2013/11/27/install-boost-on-ubuntu/

List of commands I executed are:

sudo apt-get update
sudo apt-get -y --purge remove libboost-all-dev libboost-doc libboost-dev
sudo apt-get -y install build-essential g++ python-dev autotools-dev libicu-dev libbz2-dev
cd /tmp
wget http://downloads.sourceforge.net/project/boost/boost/1.73.0/boost_1_73_0.tar.gz
tar -zxvf boost_1_73_0.tar.gz
cd boost_1_73_0
./bootstrap.sh --prefix=/usr/local
cpuCores=`cat /proc/cpuinfo | grep "cpu cores" | uniq | awk '{print $NF}'`
echo "Available CPU cores: "$cpuCores
sudo ./b2 --with=all -j $cpuCores install

After this:

./bootstrap.sh --prefix=/usr && ./b2 stage threading=multi link=shared
./b2 install threading=multi link=shared && ln -svf detail/sha1.hpp /usr/include/boost/uuid/sha1.hpp  

./b2 command prints

ln: failed to create symbolic link '/usr/include/boost/uuid/sha1.hpp': Permission denied

Then:

sudo apt update
sudo apt install libboost-all-dev

And trying to compile the smart contract:

eosio-cpp documentid.cpp -o documentid.wasm

Its giving error:

 fatal error: 'boost/uuid/uuid.hpp' file not found

Can somebody tell what I am doing wrong?

I followed all your steps and compiled this code

#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <iostream>
int main() {
    boost::uuids::uuid uuid = boost::uuids::random_generator()();
    std::cout << uuid << std::endl;
    return 0;
}

Then I compiled with c++ -Wall -std=c++17 -g -I /usr/local/include/ uuid_test.cpp -o uuid_test and it worked fine. Telling the linker where to find the uuid.hpp is done with the -I flag.

I got a similar problem while installing AlmaBTE in ubuntu 20.04

/home/sy/applications/almabte-v1.3.2/src/superlattice_builder.cpp:38:10: fatal error: boost/uuid/sha1.hpp: No such file or directory
   38 | #include <boost/uuid/sha1.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [src/CMakeFiles/superlattice_builder.dir/build.make:63: src/CMakeFiles/superlattice_builder.dir/superlattice_builder.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:474: src/CMakeFiles/superlattice_builder.dir/all] Error 2
make: *** [Makefile:95: all] Error 2

The boost library was okay, however, I find the file 'sha1.hpp' located in another dir. So I just copied it to the right place and it worked;

sudo cp /usr/include/boost/uuid/detail/sha1.hpp /usr/include/boost/uuid/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM