📄 shlib.so
字号:
m4_comment([$Id: shlib.so,v 10.19 2006/10/05 01:06:05 bostic Exp $])define(__m4_product_name, m4_db)define(__m4_directory, build_unix)define(__m4_lib_name, libdb)define(__m4_lib_suffix, db)m4_ref_title(Building __m4_product_name for UNIX/POSIX systems, Dynamic shared libraries, @shared libraries, __m4_directory/install, ifelse(__m4_product_name, m4_xml, __m4_directory/notes, __m4_directory/test))m4_p([dnlm4_bold(Warning): the following information is intended to be generic andis likely to be correct for most UNIX systems. Unfortunately, dynamicshared libraries are not standard between UNIX systems, so there may beinformation here that is not correct for your system. If you haveproblems, consult your compiler and linker manual pages, or your systemadministrator.])m4_p([dnlThe __m4_product_name dynamic shared libraries are created with the name__m4_lib_name-m4_bold(major).m4_bold(minor).so, where m4_bold(major) isthe major version number and m4_bold(minor) is the minor version number.Other shared libraries are created if Java and Tcl support are enabled:specifically, __m4_lib_name[_java-]m4_bold(major).m4_bold(minor).soand __m4_lib_name[_tcl-]m4_bold(major).m4_bold(minor).so.])m4_p([dnlOn most UNIX systems, when any shared library is created, the linkerstamps it with a "SONAME". In the case of __m4_product_name, the SONAMEis __m4_lib_name-m4_bold(major).m4_bold(minor).so. It is important torealize that applications linked against a shared library remember theSONAMEs of the libraries they use and not the underlying names in thefilesystem.])m4_p([dnlWhen the __m4_product_name shared library is installed, links arecreated in the install lib directory so that__m4_lib_name-m4_bold(major).m4_bold(minor).so,__m4_lib_name-m4_bold(major).so, and __m4_lib_name.so all refer to thesame library. This library will have an SONAME of__m4_lib_name-m4_bold(major).m4_bold(minor).so.])m4_p([dnlAny previous versions of the __m4_product_name libraries that arepresent in the install directory (such as __m4_lib_name-2.7.so or__m4_lib_name-2.so) are left unchanged. (Removing or moving old sharedlibraries is one drastic way to identify applications that have beenlinked against those vintage releases.)])m4_p([dnlOnce you have installed the __m4_product_name libraries, unless they areinstalled in a directory where the linker normally looks for sharedlibraries, you will need to specify the installation directory as partof compiling and linking against __m4_product_name. Consult your systemmanuals or system administrator for ways to specify a shared librarydirectory when compiling and linking applications with the__m4_product_name libraries. Many systems support environment variables(for example, LD_LIBRARY_PATH or LD_RUN_PATH), or system configurationfiles (for example, /etc/ld.so.conf) for this purpose.])m4_p([dnlm4_bold(Warning): some UNIX installations may have an already existingm4_path(/usr/lib/__m4_lib_name.so), and this library may be an incompatibleversion of __m4_product_name.])m4_p([dnlWe recommend that applications link against __m4_lib_name.so (for example,using [-l]__m4_lib_suffix). Even though the linker uses the file named__m4_lib_name.so, the executable file for the application remembers thelibrary's SONAME (__m4_lib_name-m4_bold(major).m4_bold(minor).so). Thishas the effect of marking the applications with the versions they needat link time. Because applications locate their needed SONAMEs whenthey are executed, all previously linked applications will continue torun using the library they were linked with, even when a new version of__m4_product_name is installed and the file m4_path(__m4_lib_name.so)is replaced with a new version.])m4_p([dnlApplications that know they are using features specific to a particular__m4_product_name release can be linked to that release. For example, anapplication wanting to link to __m4_product_name major release "3" can linkusing [-l]__m4_lib_suffix[-3], and applications that know about a particularminor release number can specify both major and minor release numbers;for example, [-l]__m4_lib_suffix[-3.5.]])m4_p([dnlIf you want to link with __m4_product_name before performing libraryinstallation, the "make" command will have created a shared libraryobject in the m4_path(.libs) subdirectory of the build directory, suchas m4_path(build_unix/.libs/__m4_lib_name-major.minor.so). If you wantto link a file against this library, with, for example, a major numberof "3" and a minor number of "5", you should be able to do somethinglike the following:])m4_indent([dnlcc -L BUILD_DIRECTORY/.libs -o testprog testprog.o [-l]__m4_lib_suffix[-3.5]env LD_LIBRARY_PATH="BUILD_DIRECTORY/.libs:$LD_LIBRARY_PATH" ./testprog])m4_p([dnlwhere m4_bold(BUILD_DIRECTORY) is the full directory path to the directorywhere you built __m4_product_name.])m4_p([dnlThe libtool program (which is configured in the build directory) can beused to set the shared library path and run a program. For example,the following runs the gdb debugger on the db_dump utility after settingthe appropriate paths:])m4_indent([libtool gdb db_dump])m4_p([dnlLibtool may not know what to do with arbitrary commands (it is hardwiredto recognize "gdb" and some other commands). If it complains the modeargument will usually resolve the problem:])m4_indent([libtool --mode=execute my_debugger db_dump])m4_p([dnlOn most systems, using libtool in this way is exactly equivalent tosetting the LD_LIBRARY_PATH environment variable and then executing theprogram. On other systems, using libtool has the virtue of knowing aboutany other details on systems that don't behave in this typical way.])m4_page_footer
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -