Description
Protobuf has been fully migrated to GitHub, address: https://github.com/google/protobuf
Download Direct 2.6.1 Version: Https://github.com/google/protobuf/archive/v2.6.1.zip
I turned to Linux soon so the various system paths to Linux are not particularly familiar with the online read a few tutorials are not mentioned
Add Library_path path, resulting in a custom installation path when the link is not (especially the default installation path of non-root users do not have permissions, you need to modify the installation installation path), so write an installation tutorial yourself, also counted as a deepening impression, I hope to be helpful to everyone.
Default installation steps (Root permission required):
$wGethttps:Github.com/google/protobuf/archive/v2. 6. 1. zip$uNzip protobuf-2.6. 1. zip$cD protobuf-2.6. 1The code downloaded from GitHub needs to be executed first$ ./autogen.sh Build Configure File$ ./configure$ Make$ Make check$ Make install I am using the CentOS system Usr/local/binusr/local/lib,usr/local/include is also one of the system default paths, so you can use PROTOBUF in this step$ Protoc-I=./--cpp_out=./Test.proto to the directory where your test.proto files use the command Protoc-I=./--cpp_out=./GenerationC+ + version of protocol file everythingOKThen you see the. h and. cc files back in the current directory
Modify the installation path (non-root users need to modify the installation path):
Protobuf default installation in the/usr/local directory you can modify the installation directory through the./configure--prefix= Command Although I am the root user but feel that the default installation is too fragmented, so the unified installation under/usr/local/protobuf $./ Configure--prefix=/usr/local/protobuf$ make$ make check$ make install to this step is not complete,/etc/profile or user directory ~/. bash_profile Add the following####### Add protobuf lib path ######### (Dynamic Library search path) when you find a dynamic link library in a program load run, specify a path other than the system default pathExportLd_library_path=$LD _library_path:/usr/local/protobuf/lib/# (Static library search path) specifies the path to find shared libraries when locating a dynamic link library during a program compilationExportLibrary_path=$LIBRARY _path:/usr/local/protobuf/lib/#执行程序搜索路径ExportPath=$PATH:/usr/local/protobuf/bin/#c程序头文件搜索路径ExportC_include_path=$C _include_path:/usr/local/protobuf/include/#c + + program header file search pathExportCplus_include_path=$CPLUS _include_path:/usr/local/protobuf/include/#pkg-config PathExportPkg_config_path=/usr/local/protobuf/lib/pkgconfig/######################################All right, goog luck.
Additional Gifts:
If there are no symbols and link errors found, please remember to add the link option-lprotobuf
and verify that your static library path is in effect.
Echo $LIBRARY _path
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Install Google Protobuf under Linux (verbose)