问题

按如下步骤在Ubuntu上编译安装Google Protocol Buffers

$ ./configure 
$ make
$ make check
$ sudo make install

运行

$ protoc --version 

出现找不到动态库的错误

protoc: error while loading shared libraries: libprotobuf.so.7: cannot open shared object file: No such file or directory 

原因

protobuf的默认安装位置是 /usr/local/usr/local/lib 不在Ubuntu系统默认的 LD_LIBRARY_PATH 里。这个问题 protobuf 的README.txt 写得很清楚,怪自己不仔细。

** Hint on install location **

By default, the package will be installed to /usr/local. However,
on many platforms, /usr/local/lib is not part of LD_LIBRARY_PATH.
You can add it, but it may be easier to just install to /usr
instead. To do this, invoke configure as follows:

./configure --prefix=/usr

If you already built the package with a different prefix, make sure
to run "make clean" before building again.

解决

参考文章里面提供了几种方法,这里只使用其中的一种。

方法1:
1. 创建文件 /etc/ld.so.conf.d/libprotobuf.conf 包含内容

/usr/local/lib

2. 运行命令

$ sudo ldconfig 

这时再运行 protoc --version 就可以得到版本号了

$ protoc --version 
libprotoc 2.4.1

方法2:

  1. vim /etc/profile
  2. export LD_LIBRARY_PATH=~/protobuf-2.5.0
  3. source /etc/profile
  4. $ sudo ldconfig

(LD_LIBRARY_PATH的这里,填写的是protobuf文件的位置)

关于Linux动态库的加载路径的更多相关文章

  1. c++ 动态库的加载

    转载:https://blog.csdn.net/ztq_12345/article/details/99677769 使用ide是vs, 使用Windows.h下的3个函数对动态库进行加载第一个:H ...

  2. linux设置库文件加载包含路径

    第一种方式vim /etc/ld.so.conf 将要包含的路径添加到此文件中退出重新登录使配置生效或者执行命令source /etc/ld.so.conf 另一种方式利用LIBRARY_PATH和L ...

  3. Linux下指定so共享库的加载路径

    转载地址:https://blog.csdn.net/zorelemn/article/details/52596293,做了部分修改 一.库文件的搜索路径: 1.在配置文件/etc/ld.so.co ...

  4. linux 下添加库的加载路径的方式

    linux 下有两种添加加载库路径的方式: 1.修改环境变量: export LD_LIBRARY_PATH=path_name 2.修改配置文件 修改 /etc/ld.so.conf 的内容在最后添 ...

  5. 动态库DLL加载方式-静态加载和动态加载

    静态加载: 如果你有a.dll和a.lib,两个文件都有的话可以用静态加载的方式: message函数的声明你应该知道吧,把它的声明和下面的语句写到一个头文件中 #pragma comment(lib ...

  6. qt在动态库里面加载widget的例子

    testDll和testExe项目 备注:windows下dll内不需要new QApplication, linux和mac下面需要在动态库里面new QApplication testdll.h ...

  7. c#生成动态库并加载

    下面这段代码生成dll文件,不能编译运行.点击项目右键,点击生成,这时会在debuge文件中生成相应的配置文件. using System; using System.Collections.Gene ...

  8. linux动态库默认搜索路径设置的三种方法

    众所周知, Linux 动态库的默认搜索路径是 /lib 和 /usr/lib .动态库被创建后,一般都复制到这两个目录中.当程序执行时需要某动态库, 并且该动态库还未加载到内存中,则系统会自动到这两 ...

  9. Linux动态库(.so)搜索路径

    主要内容: 1.Linux动态库.so搜索路径 编译目标代码时指定的动态库搜索路径: 环境变量LD_LIBRARY_PATH指定的动态库搜索路径: 配置文件/etc/ld.so.conf中指定的动态库 ...

随机推荐

  1. [Algorithm] Serialize and Deserialize Binary Tree

    Given the root to a binary tree, implement serialize(root), which serializes the tree into a string, ...

  2. iOS8开发~Swift(二)Playground

    一.Playground介绍 Playground是Xcode6中自带的Swift代码开发环境.俗话说"功欲善其事,必先利其器".曾经在Xcode5中编写脚本代码.比如编写JS.其 ...

  3. 【pyhon】理想论坛爬虫1.08

    #------------------------------------------------------------------------------------ # 理想论坛爬虫1.08,用 ...

  4. 基于XMPP 协议的开发 android

    设计过一款基于开源的XMPP即时通信协议的软件.採用C/S协议,通过GPRS无线网络用TCP协议到server.以架设开源的Openfire server作为即时通讯平台 系统主要由下面部分组成:一是 ...

  5. UITableViewCell 取消选中的蓝色背景

    方案一: [self.tableView setAllowsSelection:NO]; 方案二: [cell setSelectionStyle:UITableViewCellSelectionSt ...

  6. TQ2440 LCD试验失败经验教训

    试验环境:TQ2440开发板(配套TQ4.3寸屏) 试验参考书目:<ARM处理器裸机开发实战--机制而非策略>(以下简称<裸机开发实战>) <裸机开发实战>第13章 ...

  7. MySQL工具1:mysqladmin

    每两秒显示一下MySQL的状态,一共显示5次. # mysqladmin -uroot -p -i 2 -c 5 status 查看MySQL的运行状态: #mysqladmin -uroot -p ...

  8. ERROR 1227 (42000): Access denied; you need (at least one of) the SUPER privilege(s) for this operation

    开启super权限: 1. update user set Super_priv=‘Y’ where User=‘root’2. flush privileges

  9. iOS 推断设备为iPhone还是iPad

    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { self.viewControlle ...

  10. 〖Linux〗zigbee实验之cc2430的cc debugger固件升级实录

    开发环境:Windows XP 1. (Trouble)一开始,使用IAR提示此设备不可使用(意味着无法下载程序): 2. (Search)通过一番的仔细查找,发现是cc debugger的Evalu ...