2.3 Shared Libraries
2018-05-10 17:45
211 查看
2.3 Shared Libraries
To run a program linked with the shared version of the library the operating system must be able to locate the corresponding .so file at runtime. If the library cannot be found, the following error will occur:
$ ./a.out
./a.out: error while loading shared libraries:
libgsl.so.0: cannot open shared object file: No such
file or directory
To avoid this error, either modify the system dynamic linker configuration5 or define the shell variable LD_LIBRARY_PATH to include the directory where the library is installed.
For example, in the Bourne shell (/bin/sh or /bin/bash), the library search path can be set with the following commands:
$ LD_LIBRARY_PATH=/usr/local/lib
$ export LD_LIBRARY_PATH
$ ./example
In the C-shell (/bin/csh or /bin/tcsh) the equivalent command is,
% setenv LD_LIBRARY_PATH /usr/local/lib
The standard prompt for the C-shell in the example above is the percent character ‘%’, and should not be typed as part of the command.
To save retyping these commands each session they can be placed in an individual or system-wide login file.
To compile a statically linked version of the program, use the -static flag in gcc,
$ gcc -static example.o -lgsl -lgslcblas -lm
source: https://www.gnu.org/software/gsl/manual/html_node/Shared-Libraries.html
To run a program linked with the shared version of the library the operating system must be able to locate the corresponding .so file at runtime. If the library cannot be found, the following error will occur:
$ ./a.out
./a.out: error while loading shared libraries:
libgsl.so.0: cannot open shared object file: No such
file or directory
To avoid this error, either modify the system dynamic linker configuration5 or define the shell variable LD_LIBRARY_PATH to include the directory where the library is installed.
For example, in the Bourne shell (/bin/sh or /bin/bash), the library search path can be set with the following commands:
$ LD_LIBRARY_PATH=/usr/local/lib
$ export LD_LIBRARY_PATH
$ ./example
In the C-shell (/bin/csh or /bin/tcsh) the equivalent command is,
% setenv LD_LIBRARY_PATH /usr/local/lib
The standard prompt for the C-shell in the example above is the percent character ‘%’, and should not be typed as part of the command.
To save retyping these commands each session they can be placed in an individual or system-wide login file.
To compile a statically linked version of the program, use the -static flag in gcc,
$ gcc -static example.o -lgsl -lgslcblas -lm
source: https://www.gnu.org/software/gsl/manual/html_node/Shared-Libraries.html
相关文章推荐
- 第二章:2.3 卷积定义(卷积积分与卷积和)
- 学习Linux-4.12内核网路协议栈(2.3)——接口层数据包的接收(下半部)
- 词向量源码解析:(2.3)word2vec源码解析之word2vec
- ESL作业笔记2.3:均匀分布情况下最近邻距离的中值
- 回顾大一·C语言编程2.3(2)
- opencart 2.3全面伪静态
- opencart 2.3全面伪静态
- iOS倒计时-swift2.3
- Studio2.3 Error:Execution failed for task ':app:transformNative_libsWithStripDebugSymbolForRelease'
- 在Eclipse中运行Nutch2.3
- windows下编译最新版ffmpeg3.3-android,并通过CMake方式移植到Android studio2.3中
- 自学Zabbix2.3-服务器端server安装过程
- struts2.3纠缠了几天,unknown location,找不到Action问题
- 解决Maven update后项目出现Dynamic Web module 变成2.3错误
- Android 2.3应用开发实战pdf
- 2.3关系模型
- ubuntu 16.04 Android studio 2.3开发环境搭建
- 2.1/2.2 系统目录结构 2.3 ls命令 2.4 文件类型 2.5 alias命令
- 2.3
- 在JSP中应用FCKeditor(2.1.1和FCKeditor.Java 2.3)