ubuntu下安装protobuf及cmake编译

1.下载protobuf

https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz

cd 到下载目录,并解压tar -zxvf protobuf-2.6.1.tar.gz

2. cd到解压后的文件夹

cd ../protobuf-2.6.1/

注:我是将文件复制到个人用户目录下了

3.执行 ./autogen.sh

./autogen.sh

出现以下问题:

+ sed -i -e s/RuntimeLibrary="5"/RuntimeLibrary="3"/g;
           s/RuntimeLibrary="4"/RuntimeLibrary="2"/g; gtest/msvc/gtest-md.vcproj gtest/msvc/gtest.vcproj gtest/msvc/gtest_main-md.vcproj gtest/msvc/gtest_main.vcproj gtest/msvc/gtest_prod_test-md.vcproj gtest/msvc/gtest_prod_test.vcproj gtest/msvc/gtest_unittest-md.vcproj gtest/msvc/gtest_unittest.vcproj
+ autoreconf -f -i -Wall,no-obsolete
Can't exec "libtoolize": 没有那个文件或目录 at /usr/share/autoconf/Autom4te/FileUtils.pm line 345,  line 6.
autoreconf: failed to run libtoolize: No such file or directory
autoreconf: libtoolize is needed because this package uses Libtool

解决方法:

sudo apt install libtool

再执行./autogen.sh

4.执行./configure

./configure 

5.执行make

make

6.执行make install

make install

7.设置环境变量

vim /etc/profile
export PATH=$PATH:/usr/local/bin
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
cd ~
vim .profile
export PATH=$PATH:/usr/local/bin
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

8.配置动态链接库路径

vim /etc/ld.so.conf
include /usr/local/lib

9.

sudo ldconfig

10.查看是否安装成功

protoc --version

安装成功输出:

libprotoc 2.6.1

 

参考链接文章:https://www.cnblogs.com/aelite/p/9026885.html

                            https://blog.csdn.net/blue_it/article/details/53996216

 

你可能感兴趣的:(ubuntu下安装protobuf及cmake编译)