关于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中指定的动态库 ...
随机推荐
- Node.js程序在node-windows中不能运行
Node.js程序部分功能在命令行中运行良好,但在node-windows中不能运行,怎么回事? 答:路径问题. 请看如下的描述: My script runs fine on it's own, ...
- Http具体解释
一.Http是位于网络层的超文本传输协议. 我们用浏览器浏览网页就是用的http协议实现的. 二.Http请求详细分析 我们能够用httpwatch工具对http进行抓包分析 下面就是请求www.si ...
- Discuz常见小问题-无法登陆UCenter怎么办
打开uc_server/model/admin.php找到第22行的$this->cookie_status = 0;改成$this->cookie_status = isset($_CO ...
- linux 文件查找,which,whereis,locate,find
linux 文件查找,which,whereis,locate,find 一:which 主要用于查找可执行命令的所在位置: 如图,查找命令 ls的目录: 二:whereis 主要用于查找命令的帮助文 ...
- 除掉inline-block 间距
1.现象: <!doctype html> <html lang="en"> <head> <meta charset="UTF ...
- Memcached安装与配置
memcached是danga.com的一个项目.它是一款开源的高性能的分布式内存对象缓存系统.最早是给LiveJournal提供服务的.后来逐渐被越来越多的大型站点所採用.用于在应用中减少对数据库 ...
- eclipse下使用cygwin的方法(Windows下用eclipse玩gcc/g++和gdb)
明天就回国了,今晚回国前写写如何配置eclipse和CDT.这个配置方法网上讨论不是很多,可能用的人少,毕竟Windows上写C++程序多数喜欢VS,即使写的是Linux程序,很多人仍然会用VS(说只 ...
- result_charts
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...
- ListView中Button事件
为了解决ListView中Item里的Button独立事件响应,能够採用下面方法: 在BaseAdapter的getview里加入加粗代码: <span style="font-siz ...
- 转载:PHP JSON_ENCODE 不编码中文汉字的方法
1.PHP版本5.4(包含)+ json_encode($data, JSON_UNESCAPED_UNICODE); //必须PHP5.4+ 2.PHP版本5.4- function encode_ ...