Linux: Set OR Change The Library Path
Linux: Set OR Change The Library Path
by NIX CRAFT on APRIL 9, 2010 · 3 COMMENTS· LAST UPDATED AUGUST 11, 2013
in GNU C / C++, LINUX, PROGRAMMING
I've compile and installed a library at /usr/local/lib/libapp2.so -> libapp2.so.1.4.3. How do I set the Library path under Linux operating systems?
You need to use ldconfig config file and ldconfig command which creates the necessary links and cache to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.so.conf, and in the trusted directories such as /lib64 or /usr/lib64 (/lib or /usr/lib on 32 bit systems).
Tutorial details
Difficulty
Intermediate (rss)
Root privileges
Yes
Requirements
GNU gcc
Estimated completion time
10m
The /etc/ld.so.conf contains lib settings which can be used to add or delete paths. However, you need to simply drop your config file in /etc/ld.so.conf.d/ directory and it will be used by /sbin/ldconfig to configure dynamic linker run time bindings.
Add Your Path
Create a file called /etc/ld.so.conf.d/myapp.conf:# vi /etc/ld.so.conf.d/myapp.conf
Add the following path:
/usr/local/lib
Save and close the file.
Activate Your Library Path
You must run the following command to activate path:# ldconfig
Verify Your New Library Path
# ldconfig -v | less
OR# ldconfig -v | grep /usr/local/lib
Sample outputs:
/usr/local/lib:
libGeoIP.so.1 -> libGeoIP.so.1.4.6
libGeoIPUpdate.so.0 -> libGeoIPUpdate.so.0.0.0
/usr/lib64/mysql:
libmysqlclient_r.so.15 -> libmysqlclient_r.so.15.0.0
libmysqlclient.so.15 -> libmysqlclient.so.15.0.0
/lib:
libutil.so.1 -> libutil-2.5.so
How Do I Delete The Library Path?
Simply, delete the file:# rm /etc/ld.so.conf.d/myapp.conf
# ldconfig
How Do I Edit The Library Path?
Simply edit the file and reload the changes:# vi /etc/ld.so.conf.d/myapp.conf
# ldconfig
How Do I Compile Program With Shared Libs And GNU GCC?
You can use the following gcc$ gcc -Wl,-R/path/to/lib -I/path/to/include -L/path/to/lib -o myAppName mycode.c -llibapp2
Linux: Set OR Change The Library Path的更多相关文章
- Java加载dll或so库文件的路径 java.library.path
1. Java的System.load 和 System.loadLibrary都可以用来加载库文件 2.例如你可以这样载入一个windows平台下JNI库文件: System.load(&q ...
- no ocijdbc11 in java.library.path linux
no ocijdbc11 in java.library.path linux vi /etc/profile export ORACLE_HOME=/oracle/database/oracle/p ...
- java出现no XXX in java.library.path的解决办法及eclipse配置
java一般使用两个path:classpath 和 java.library.path classpath是指向jar包的位置 java.library.path是非java类包的位置如(dll,s ...
- java.lang.UnsatisfiedLinkError: no XXX in java.library.path
其中涉及的测试源码如下: For those who didn't install Javawith default settings, a systematic way for solving JN ...
- 不同系统与程序修改java.library.path的位置(转)
原文地址:http://blog.csdn.net/quqibing001/article/details/51201768 Linux环境 系统变量LD_LIBRARY_PATH来添加Java.li ...
- no libsigar-amd64-linux.so in java.library.path 解决方法
关于sigar的介绍可以参考这边博文 :https://www.cnblogs.com/luoruiyuan/p/5603771.html 在Linux上运行java程序时出现 no libsigar ...
- no xxx find in java.library.path
JAVA系统运行时候load native lib时候会遇到下面错误,如 java.lang.UnsatisfiedLinkError: no JSTAF in java.library.path这可 ...
- 异常:没有找到本地方法库,java.lang.UnsatisfiedLinkError: no trsbean in java.library.path
1.问题描述 迁移环境中遇到这个问题 : Fri Apr 20 15:22:31 CST 2018, Exception:500004___-500004,没有找到本地方法库,java.lang.Un ...
- The Apache Tomcat Native library which allows using OpenSSL was not found on the java.library.path 问题解决记录
1.问题 启动Tomcat之后,在浏览器输入IP后显示503,查看catalina.log发现报错: 2.问题定位:缺少 tomcat-native library 就是说 缺少Tomcat Nati ...
随机推荐
- vagrant nginx php开发环境中浏览器访问js文件,文件中出现乱码的解决方法
当nginx配置 sendfile设置为on时,某些js文件中会出现奇怪的字符: ����������������� 不管怎么刷新,重启服务都无效: 通过google搜索之后发现原来是因为开启send ...
- C++矢量图形库系列(1)——矢量图形库乱谈(转)
转自:http://blog.sina.com.cn/s/blog_4265e1760100lg03.html 本系列篇章的主要内容是讲解矢量图形库的编译.开发和使用.并不对他们周边的内容做过多的描述 ...
- javascript基础知识-命名提前,作用域
javascript的代码存在命名提前的现象,在这里结合javascript的特殊作用域来解释. 一般很多后台语言,比如C#都是块级作用域,也就是花括号范围内定义的变量,作用域被限制在花括号以内. 而 ...
- Maven 跳过测试命令行参数 skip test
mvn package -Dmaven.test.skip=true
- 使用lock和condition实现的阻塞队列-字符串
在jdk 的API中提供了一个字符串的阻塞队列 : class BoundedBuffer { final Lock lock = new ReentrantLock(); final Conditi ...
- innodb_ft_max_token_size取值范围
根据问档中所说,innodb_ft_max_token_size取值范围为10-252,而实际上但我们在配置文件设置innodb_ft_max_token_size=252时,error log会出现 ...
- mac os安装基本的install环境,命令行安装软件
以下摘自:homebrew官网. 在 OS X 中找不到您想要的软件?Homebrew 给你所需. 首先需要安装一个很多人都在用的包:homebrew 安装 Homebrew 开 Terminal, ...
- C#设计模式(22)——访问者模式(Vistor Pattern)
一.引言 在上一篇博文中分享了责任链模式,责任链模式主要应用在系统中的某些功能需要多个对象参与才能完成的场景.在这篇博文中,我将为大家分享我对访问者模式的理解. 二.访问者模式介绍 2.1 访问者模式 ...
- C语言 栈 链式结构 实现
一个C语言链式结构实现的栈 mStack (GCC编译). /** * @brief C语言实现的链式结构类型的栈 * @author wid * @date 2013-10-30 * * @note ...
- MySql、SqlServer、Oracle 三种数据库查询分页方式
SQL Server关于分页 SQL 的资料许多,有的使用存储过程,有的使用游标.本人不喜欢使用游标,我觉得它耗资.效率低:使用存储过程是个不错的选择,因为存储过程是颠末预编译的,执行效率高,也更灵活 ...