码迷,mamicode.com
首页 > 系统相关 > 详细

Linux 动态链接库学习笔记

时间:2015-11-17 12:36:03      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:

参考资料:

 

1.

-fpic

Generate position-independent code (PIC) suitable for use in a shared library, if supported for the target machine. Such code accesses all constant addresses through a global offset table (GOT). The dynamic loader resolves the GOT entries when the program starts (the dynamic loader is not part of GCC; it is part of the operating system). If the GOT size for the linked executable exceeds a machine-specific maximum size, you get an error message from the linker indicating that-fpicdoes not work; in that case, recompile with-fPICinstead. (These maximums are 8k on the SPARC and 32k on the m68k and RS/6000. The x86 has no such limit.)

Position-independent code requires special support, and therefore works only on certain machines. For the x86, GCC supports PIC for System V but not for the Sun 386i. Code generated for the IBM RS/6000 is always position-independent.

这是编译器选项

2.

-shared

Produce a shared object which can then be linked with other objects to form an executable. Not all systems support this option. For predictable results, you must also specify the same set of options used for compilation (-fpic,-fPIC, or model suboptions) when you specify this linker option.

这是链接器选项

3.

dlfcn.h

这个头文件包含了 dlopen, dlsym, dlclose, dlerror 等等与动态链接库操作相关的函数

类似于Windows 中的 LoadLibrary, GetProcAddress 等等

4.

 

Linux 动态链接库学习笔记

标签:

原文地址:http://www.cnblogs.com/qrlozte/p/4971088.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!