PROTOCOL BUFFER ERROR due to incompatible versions - c++

I am trying to compile on ubuntu 18.04 and receive the following error -
file.pb.h:17:2: error: #error This file was generated by an older version of protoc which is
#error This file was generated by an older version of protoc which is
protoc --version
libprotoc 3.6.1
from google/protobuf/stubs/common.h
#define GOOGLE_PROTOBUF_VERSION 3006001
So looks like the versions match.
I did do a remove of any older versions just in case using the following link
https://www.howtoinstall.co/en/ubuntu/trusty/protobuf-compiler?action=remove
What am I missing here ?

Related

Missing C++ std library methods and other errors while compiling EOS on Ubuntu 14.04?

I'm trying to compile the EOS blockchain/smart contract project on GitHub on Ubuntu 14.04:
https://github.com/EOSIO/eos
After getting Clang 4.0 to install, installing build_essentials, and upgrading CMake to 3.5, I was able to run the build process without any missing dependencies. However, now I get the errors shown below when I build the EOS source. This seems to me like another general issue with the configuration of the tools on my system since many people are able to compile the EOS code, although usually on Ubuntu 14.04.
Can anyone tell by looking at the errors I'm getting what tool or library I need to install or upgrade?
In file included from /usr/lib/llvm-4.0/include/clang/AST/Decl.h:31:
/usr/lib/llvm-4.0/include/llvm/Support/TrailingObjects.h:259:33: error: 'BaseTy' does not refer to a value
static_assert(LLVM_IS_FINAL(BaseTy), "BaseTy must be final.");
^
/usr/lib/llvm-4.0/include/llvm/Support/TrailingObjects.h:233:20: note: declared here
template <typename BaseTy, typename... TrailingTys>
^
/usr/lib/llvm-4.0/include/llvm/Support/TrailingObjects.h:259:19: error: expected expression
static_assert(LLVM_IS_FINAL(BaseTy), "BaseTy must be final.");
^
/usr/lib/llvm-4.0/include/llvm/Support/type_traits.h:104:45: note: expanded from macro 'LLVM_IS_FINAL'
#define LLVM_IS_FINAL(Ty) std::is_final<Ty>()
^
Linking CXX executable codegen
/home/robert/Documents/GitHub/eos/programs/launcher/main.cpp:405:18: error: no template named 'underlying_type_t' in namespace 'std'; did you mean
'underlying_type'?
using T = std::underlying_type_t <enum_type>;
~~~~~^~~~~~~~~~~~~~~~~
underlying_type
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/type_traits:1855:12: note: 'underlying_type' declared here
struct underlying_type
^
/home/robert/Documents/GitHub/eos/programs/launcher/main.cpp:435:17: error: no member named 'put_time' in namespace 'std'
dstrm << std::put_time(std::localtime(&now_c), "%Y_%m_%d_%H_%M_%S");
~~~~~^
[ 64%] Building CXX object libraries/chain/CMakeFiles/eos_chain.dir/chain_controller.cpp.o
/home/robert/Documents/GitHub/eos/programs/launcher/main.cpp:406:39: error: no matching conversion for static_cast from 'allowed_connection' to 'T'
(aka 'underlying_type<allowed_connection>')
return lhs = static_cast<enum_type>(static_cast<T>(lhs) | static_cast<T>(rhs));
^~~~~~~~~~~~~~~~~~~
The Missing _t alias names look like you’re having issues with C++14. The header paths in the error messages look like you’re using the standard library from GCC 4.8 (the default compiler on Ubuntu 14.04), which is simply too old.
I can see two solutions:
Switch from GCC’s libstdc++ to an up-to-date version of LLVM’s libc++. I’m not familiar enough with Ubuntu to tell you how to install it. For the compilation of EOSIO you must pass the -stdlib=libc++ option to Clang to switch to the different stdlib. EOSIO looks like it’s using CMake, so you have to include -DCMAKE_CXX_FLAGS=-stdlib=libc++ in your CMake command line.
Use the Toolchain test builds PPA to install a newer GCC and and libstdc++ in addition to your system’s default one. For Ubuntu 14.04 GCC 7.2.0 is the latest version available, which is perfectly C++14 capable. Add the PPA to your package sources and then do a:
sudo apt-get install gcc-7 g++-7
This installs both the GCC C compiler and C++ compiler along with the stdlib. Your default compiler is still going to be the old GCC 4.8, so you’ll have to tell CMake about the newer versions:
-DCMAKE_CXX_COMPILER=g++-7 -DCMAKE_C_COMPILER=gcc-7
Note that now you compile EOSIO with GCC (and the new stdlib) instead of Clang. Instructing Clang to use a specific version of libstdc++ should be possible, but I don’t know how.
Official support is for Ubuntu 16.10. Consider upgrading.
(EDITED: I mistakenly said 14.10)
Source: https://github.com/EOSIO/eos/wiki/Local-Environment#211-ubuntu-1610

Mingw32 errors when building OpenCV 3.2.0 on Windows 7

I'm trying to build OpenCV 3.2.0 vc14 from its sources with MinGW 5.3.0 32 bit in order to use its functionality from Qt 5.8. My platform is Windows 7 64 bit.
The main instruction I follow is here, on Qt's wiki. On several steps, I encounter errors for which I haven't found solutions yet. As I am a newbie, I apologize for my helplessness and will appriciate any suggestions.
Error 1. On the stage of generating build files.
In cmake-gui (cmake-3.2.1-win32-x86), I precisely follow the steps specified in the Qt wiki article mentioned above. However, during the final generation, the following CMake error occurs at the end:
CMake Error in modules/highgui/CMakeLists.txt:
No known features for CXX compiler
"GNU"
version 5.3.0.
Generating done
I wonder how it affects the project files and if it causes the next errors.
Error 2. When trying to build OpenCV
The build process is interrupted midway, logging the following:
In file included from C:/Qt/Tools/mingw530_32/i686-w64-
mingw32/include/c++/type_
traits:35:0,
from C:/Qt/5.8/mingw53_32/include/QtCore/qglobal.h:45,
from C:/Qt/5.8/mingw53_32/include/QtCore/QtCore:4,
from C:/Qt/5.8/mingw53_32/include/QtOpenGL/QtOpenGLDepends:3,
from C:/Qt/5.8/mingw53_32/include/QtOpenGL/QtOpenGL:3,
from C:/opencv/sources/modules/highgui/src/window_QT.h:46,
from C:\opencv\sources\modules\highgui\src\window_QT.cpp:47:
C:/Qt/Tools/mingw530_32/i686-w64-
mingw32/include/c++/bits/c++0x_warning.h:32:2:
error: #error This file requires compiler and library support for the ISO
C++ 2011 standard. This support is currently experimental, and must be
enabled with the -std=c++11 or -std=gnu++11 compiler options.
(...)
C:/Qt/5.8/mingw53_32/include/QtCore/qcompilerdetection.h:562:6: error:
#error Qt requires a C++11 compiler and yours does not seem to be that.
(...)
^
C:/Qt/5.8/mingw53_32/include/QtCore/qtypeinfo.h:62:40: error: expected
primary-expression before '>' token isIntegral = std::is_integral<T>::value,
^
C:/Qt/5.8/mingw53_32/include/QtCore/qtypeinfo.h:62:41: error: '::value' has
not been declared isIntegral = std::is_integral<T>::value,
NOTE: I also had sprintf() family security error. So I followed Alex's suggestion to add add_definitions(-DSTRSAFE_NO_DEPRECATE) to the beginning of CMakeLists.txt to suppress the error.
Thank you for your time.

Protobuf on Ubuntu not compiling

I could not compile with protobuf on ubuntu. Here is the error:
error: #error This file was generated by a newer version of protoc which is
#error This file was generated by a newer version of protoc which is
^
build/x86_64/gen/rtbkit/plugins/exchange/realtime-bidding.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
#error incompatible with your Protocol Buffer headers. Please update
^
build/x86_64/gen/rtbkit/plugins/exchange/realtime-bidding.pb.h:14:2: error: #error your headers.
#error your headers.
^
In file included from build/x86_64/gen/rtbkit/plugins/exchange/realtime- bidding.pb.cc:5:0:
build/x86_64/gen/rtbkit/plugins/exchange/realtime-bidding.pb.h:26:55: fatal error: google/protobuf/generated_enum_reflection.h: No such file or directory
#include
^
I removed it, it still shows protobuf 2.5
This is a common problem with protobuf. You need to check carefully which protoc you are using, and which headers your are using, this is especially true if you have 2 versions installed!
In the header file .pb.h, you will find the protobuf version used:
#if GOOGLE_PROTOBUF_VERSION < 2006000
Check if this is supposed to be the protoc version you should used.
After that check what are the protobuf header you are using.
If there is no correlation between your protoc version and your protobuf headers you have the message displayed.

dsr/linkcache .cc: fatal error: list.h: no such file or directory

I am using NS2.35 and Ubuntu 12.04.5 LTS
I want to run DSR using link cache.
I uesd "make" to recompile NS2. I got the following error:
dsr/linkcache .cc: fatal error: list.h: no such file or directory.
I used locate list.h and this is its directory
/usr/src/linux-headers-3.2.0-29/include/linux/list.h
That means the header file exists
How can I solve this error ?
ns2 : Old files. The gcc 2.95 header list.h is included in a couple of files. And is simply ignored in a stock ns2, when g++ is later than version 3.x :
list.h is also present in gcc 3.2, 3.3, 3.4 : /usr/include/c++/3.4.6/backward/list.h
Besides that, a similar question is answered here make command not working in NS 2.35

Compile with Intel 12.1.3 using gcc4.7 std library

I'm having the same problem described in this post except I'm using Intel version 12.1.3. (g++'s header <functional> is protected with #ifdef __GXX_EXPERIMENTAL_CXX0X__ which is not defined when icpc is used.)
Instead of using boost::functional, I wanted to install gcc4.7 and use it's std libraries.
In Ubuntu 11.10 I have gcc4.6.1 but I also installed gcc4.7 from the gcc-snapshot package.
Intel has the options -gcc-name, -gxx-name, and -cxxlib.
So originally I compiled with:
-std=c++0x -gcc-name=/usr/lib/gcc-snapshot/bin/gcc -gxx-name=/usr/lib/gcc-snapshot/bin/g++ -cxxlib=/usr/lib/gcc-snapshot/
but I get the error:
icpc: error #10282: file
'/usr/lib/gcc-snapshot/bin/usr/lib/gcc-snapshot/bin/g++' not found,
generated based on '-cxxlib=/usr/lib/gcc-snapshot/'
So then I compiled with:
-std=c++0x -gcc-name=./gcc -gxx-name=./g++ -cxxlib=/usr/lib/gcc-snapshot/.
But I still get the warnings and errors:
Warning #2928: the __GXX_EXPERIMENTAL_CXX0X__ macro is disabled when using GNU version 4.6 with the c++0x option
error: namespace "std" has no member "function"
The warning clearly says it's still using version 4.6. Does anybody know how to get Intel to use the correct libraries?
I've found that if you compile with gcc (or g++) with flags -v -Q you get a list of flags and defines. It might help you see what gcc does so maybe you can use the same -D/-U in icpc. also g++ -E will preprocess without compiling: you can get useful path information from that.