一、下载protobuf2.6.1
源码地址:https://github.com/google/protobuf/releases
二、编译pc版本
1.解压protobuf-2.6.1.tar.gz
2.配置参数,本人只指定了安装目录/home/work/protobuf/pc_protobuf
./configure --prefix=/home/work/protobuf/pc_protobuf
3.make
4.make install
这样我们在/home/work/protobuf/pc_protobuf看见编译成功的三个文件夹。
三、编译海思版本
1.配置参数
./configure --host=arm-linux CC=arm-hisiv200-linux-gcc CXX=arm-hisiv200-linux-g++ --with-protoc=/home/work/protobuff/pc_protobuf/bin/protoc --prefix=/home/work/protobuff/arm_protobuf/
特别注意:--with-protoc的配置
/*
**Note for cross-compiling**
The makefiles normally invoke the protoc executable that they just
built in order to build tests. When cross-compiling, the protoc
executable may not be executable on the host machine. In this case,
you must build a copy of protoc for the host machine first, then use
the --with-protoc option to tell configure to use it instead. For
example:
./configure --with-protoc=protoc
This will use the installed protoc (found in your $PATH) instead of
trying to execute the one built during the build process. You can
also use an executable that hasn't been installed. For example, if
you built the protobuf package for your host machine in ../host,
you might do:
./configure --with-protoc=../host/src/protoc
Either way, you must make sure that the protoc executable you use
has the same version as the protobuf source code you are trying to
use it with.
*/
2.make
3.make install
这样我们在/home/work/protobuff/arm_protobuf/看到编译成功的三哥文件夹。