Linux Installation Protobuf and cmake compilation

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.