备注:以下所有命令均使用root权限执行;
1、下载源码:https://github.com/google/protobuf/archive/v2.6.0.zip;下载gtest-1.5.0.tar.gz http://download.csdn.net/detail/lgtnt/2754110#comment
2、解压 tar -xzvf protobuf-2.6.0.tar.gz得到protobuf-2.6.0,再解压gtest得到gtest-1.5.0,复制到protobuf-2.6.0目录并重命名为gtest
3、cd protobuf-2.6.0
4、./autogen.sh 如果提示autoconf not found,请执行apt-get install autoconf安装
5、./configure
configure.ac:17: error: possibly undefined macro: AC_PROG_LIBTOOL
If this token and others are legitimate,please use m4_pattern_allow.
See the Autoconf documentation.
See the Autoconf documentation.
autoreconf: /usr/bin/autoconf Failed with exit status: 1
7、make
8、make install
protoc: error while loading shared libraries: libprotoc.so.8: cannot open shared
错误原因:
protobuf的默认安装路径是/usr/local/lib,而/usr/local/lib 不在Ubuntu体系默认的 LD_LIBRARY_PATH 里,所以就找不到该lib
protobuf的默认安装路径是/usr/local/lib,而/usr/local/lib 不在Ubuntu体系默认的 LD_LIBRARY_PATH 里,所以就找不到该lib
解决方法:
① echo "/usr/local/lib" >> /etc/ld.so.conf.d/libprotobuf.conf
② sudo ldconfig
原文链接:https://www.f2er.com/ubuntu/354952.html