关于Linux动态库的加载路径
问题
按如下步骤在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:
- vim /etc/profile
- export LD_LIBRARY_PATH=~/protobuf-2.5.0
- source /etc/profile
- $ sudo ldconfig
(LD_LIBRARY_PATH的这里,填写的是protobuf文件的位置)
关于Linux动态库的加载路径的更多相关文章
- c++ 动态库的加载
转载:https://blog.csdn.net/ztq_12345/article/details/99677769 使用ide是vs, 使用Windows.h下的3个函数对动态库进行加载第一个:H ...
- linux设置库文件加载包含路径
第一种方式vim /etc/ld.so.conf 将要包含的路径添加到此文件中退出重新登录使配置生效或者执行命令source /etc/ld.so.conf 另一种方式利用LIBRARY_PATH和L ...
- Linux下指定so共享库的加载路径
转载地址:https://blog.csdn.net/zorelemn/article/details/52596293,做了部分修改 一.库文件的搜索路径: 1.在配置文件/etc/ld.so.co ...
- linux 下添加库的加载路径的方式
linux 下有两种添加加载库路径的方式: 1.修改环境变量: export LD_LIBRARY_PATH=path_name 2.修改配置文件 修改 /etc/ld.so.conf 的内容在最后添 ...
- 动态库DLL加载方式-静态加载和动态加载
静态加载: 如果你有a.dll和a.lib,两个文件都有的话可以用静态加载的方式: message函数的声明你应该知道吧,把它的声明和下面的语句写到一个头文件中 #pragma comment(lib ...
- qt在动态库里面加载widget的例子
testDll和testExe项目 备注:windows下dll内不需要new QApplication, linux和mac下面需要在动态库里面new QApplication testdll.h ...
- c#生成动态库并加载
下面这段代码生成dll文件,不能编译运行.点击项目右键,点击生成,这时会在debuge文件中生成相应的配置文件. using System; using System.Collections.Gene ...
- linux动态库默认搜索路径设置的三种方法
众所周知, Linux 动态库的默认搜索路径是 /lib 和 /usr/lib .动态库被创建后,一般都复制到这两个目录中.当程序执行时需要某动态库, 并且该动态库还未加载到内存中,则系统会自动到这两 ...
- Linux动态库(.so)搜索路径
主要内容: 1.Linux动态库.so搜索路径 编译目标代码时指定的动态库搜索路径: 环境变量LD_LIBRARY_PATH指定的动态库搜索路径: 配置文件/etc/ld.so.conf中指定的动态库 ...
随机推荐
- [Algorithm] Largest sum of non-adjacent numbers
Given a list of integers, write a function that returns the largest sum of non-adjacent numbers. Num ...
- linux下如何查看所有的用户和组信息?
/etc/group 文件是用户组的配置文件. /etc/passwd 文件是用户的配置文件. 使用cat.more.less.head.tail以及vim等命令都可以查看.修改这两个配置文件. 说 ...
- 理解进程调度时机跟踪分析进程调度与进程切换的过程(Linux)
----------------------------------------------------------------------------------- 理解进程调度时机跟踪分析进程调度 ...
- 【React全家桶入门之十三】Redux中间件与异步action
在上一篇中我们了解到,更新Redux中状态的流程是这种:action -> reducer -> new state. 文中也讲到.action是一个普通的javascript对象.red ...
- nodejs检查已安装模块
命令行 npm ls --depth 0
- 如何不使用pthread_cancel而杀死线程
http://www.cnblogs.com/no7dw/archive/2012/09/27/2705847.html During the time I use standalone cross ...
- java数组转json
public String toJsonObject(String[] list) { String json="["; for (int i=0;i<list.length ...
- iOS-仿京东6位密码支付输入框
概述 用于安全支付的密码支付输入框. 详细 代码下载:http://www.demodashi.com/demo/10709.html 开发需求中有时候我们需要用于安全支付的功能, 需要设置APP钱包 ...
- 设置/修改centos上的swap交换分区的方法
设置centos上的swap交换分区的方法 作为linux世界里最稳定的服务器版本,rhas5一直有很大的应用面,之前一直关注的是freebsd,因为应用的需要,特别在配合mysql和oracle上r ...
- HDUOJ--Bone Collector
Bone Collector Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...