divinity76 / cacdrive

harddrive emulator using cloudatcost's "cloud storage" as a storage backend.
The Unlicense
9 stars 4 forks source link

Error compiling on Ubuntu 16.04 #3

Closed andersondn closed 5 years ago

andersondn commented 5 years ago

src/main.cpp:62:1: error: ‘shared_mutex’ does not name a type shared_mutex io_cache_mutex; ^ src/main.cpp: In function ‘void print_io_cache()’: src/main.cpp:1004:2: error: ‘io_cache_mutex’ was not declared in this scope io_cache_mutex.lock_shared(); ^ src/main.cpp: In lambda function: src/main.cpp:1029:9: error: ‘io_cache_mutex’ was not declared in this scope io_cache_mutex.lock_shared(); ^ src/main.cpp: In function ‘void cac_upload_eventually(uint64_t, uint32_t, const char, FILE)’: src/main.cpp:1152:3: error: ‘io_cache_mutex’ was not declared in this scope io_cache_mutex.lock(); ^ src/main.cpp: In function ‘void cac_get_data(Downloadcacapi&, uint64_t, uint32_t, char, FILE)’: src/main.cpp:2378:3: error: ‘io_cache_mutex’ was not declared in this scope io_cache_mutex.lock_shared(); ^

divinity76 commented 5 years ago

hmm, you're supposed to give g++ the argument -std=c++17, the errors suggests that you didn't give it -std=c++17

how did you run g++ ?

andersondn commented 5 years ago

I'm running as say in the tutorial...

anderson@Anderson-PC:~/cacdrive$ g++ src/main.cpp -std=c++17 -lcurl -lpthread -O2
src/main.cpp:62:1: error: ‘shared_mutex’ does not name a type
 shared_mutex io_cache_mutex;

anderson@Anderson-PC:~/cacdrive$ g++ --version
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609
divinity76 commented 5 years ago

going by https://stackoverflow.com/a/42302130/1067003 and https://en.cppreference.com/w/cpp/compiler_support , g++ didn't really support c++17's shared_mutex until the g++ 6.0.0 release,

can you try running

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-6 g++-6

then try to compile with

g++-6 src/main.cpp -std=c++17 -lcurl -lpthread -O2

and show me the full command line log?

divinity76 commented 5 years ago

closing due to lack of feedback. @andersondn if you still want help, provide an answer to the the previous comment