I. PROTOBUF installation
Protobuf version: 2.6.1
: Https://github.com/google/protobuf/archive/v2.6.1.zip
Go to directory after decompression
Modify autogen.sh
echo "Google Test not present. Fetching gtest-1.5.0 from the web ... "Curl http://googletest.googlecode.com/files/gtest-1.5.0.tar.bz2 | Tar jxmv gtest-1.5.0 gtest
Change the above content in autogen.sh to
wget Https://github.com/google/googletest/archive/release-1.5.0.tar.gztar XZVF RELEASE-1.5.0.TAR.GZMV googletest-release-1.5.0 Gtest
Then execute autogen.sh
./autogen.sh
will be generated in the directory.configure文件
Then run
./configuremakemake Checkmake Install
Setting environment variables
sudo vi/etc/profileexport path= $PATH:/usr/local/binexport pkg_config_path=/usr/local/lib/pkgconfigcd ~vi. Profileexport path= $PATH:/usr/local/binexport pkg_config_path=/usr/local/lib/pkgconfig
Configure the dynamic link library path
sudo vi/etc/ld.so.confinclude/usr/local/lib
sudo ldconfig
Two. Writing cmakelists
Cmake_minimum_required (VERSION 2.8) Project (DEMO1) SET (src_list test1.cpp) # Find required Protobuf Packagefind_package (Protobuf REQUIRED) if (protobuf_found) message (STATUS "Protobuf Library FOUND") Else () message (fatal_error " PROTOBUF library is needed but cant be found ") endif () include_directories (${protobuf_include_dirs}) include_directories (${cmake_current_binary_dir}) Protobuf_generate_cpp (Proto_srcs Proto_hdrs test1.proto) add_executable (Demo1 ${src_list} ${PROTO_SRCS} ${PROTO_HDRS }) Target_link_libraries (Demo1 ${protobuf_libraries}) #add_executable (Demo test1.cpp)
If you find it useful for you, please pay
Linux Installation Protobuf and cmake compilation