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 ...
随机推荐
- ubuntu12.04安装svn 1.7(转载)
ubuntu12.04安装svn 1.7 分类: ubuntu2013-10-22 16:03 239人阅读 评论(0) 收藏 举报 svnubuntu 目录(?)[+] 1.问题 在 ...
- 文件过滤器 filter
OpenFileDialog对话框的Filter属性说明: 首先说明一个示例,分析一下Filter属性的构成:“ Excel文件|*.xls ”,前面的“Excel文件”成为标签,是一个可读的字符串, ...
- Tomcat需要更改三个端口,才能在一台机器上搭载多个tomcat
1.shutdown端口.port改成与原有的不同即可 2.8080端口,需要更改. 3.默认端口
- MySQL使用小记
时间格式化: select date_format('2008-08-08 22:23:01', '%Y%m%d%H%i%s'); 去重复: use iksdb3; select distinct ` ...
- 【半平面交】bzoj1038 [ZJOI2008]瞭望塔
http://m.blog.csdn.net/blog/qpswwww/44105605 #include<cstdio> #include<cmath> #include&l ...
- DM9000网卡驱动接受数据从中断方式改成NAPI方式小记
平台是最最经典的s3c2440了,说了要做这件事情很久了,就是改几行代码,一直没有做.前几天逼了自己一下,终于给做了,拖延症患者伤不起. 以下是需要读者对napi机制有所熟悉: step1:在boar ...
- JAVA操作Mysql数据库
String driver = "com.mysql.jdbc.Driver"; String url = "jdbc:mysql://127.0.0.1:3306/ph ...
- 通过git rebase修改commit message
今天发现一个项目的git commit message中的单词拼错了,需要修改一下.但这样简单的修改,需要通过git rebase才能完成. 首先要git rebase到需要修改message的那个c ...
- Flash矢量图与位图性能对比
Flash中使用位图的性能要高于矢量图,究竟有多大区别呢?数据有最好的说服力,开始测试: 一.机器配置 二.测试过程 测试程序控制红色小球在舞台中不停匀速移动,通过改变小球数量控制实际帧率在24帧/秒 ...
- JSP的那些事儿(2)---- DWR2.0 的配置和使用
JSP的那些事儿(2)----DWR2.0 的配置和使用 分类: Web开发 JAVA 2009-04-23 15:43 999人阅读 评论(0) 收藏 举报 jspdwrjavascriptserv ...