Linux library function

xiaoxiao2021-04-05  255

Create Library Functions Under Linux 1. Introduce Use GNU Tools We How do we create your own program log library under Linux? A "program log library" is simple to say is a file containing some compiled code and data, which is good Codes and data can be used in addition to other programs afterwards. The program function library allows the entire program more modular and more easily recompiled, and it is more convenient to upgrade. The program function library can be divided into three types: static libraries, shared libraries, and dynamically loaded libraries. The static function library is to join the target program before execution; and the shared function library is loaded into the program when the program is started, it can be shared by different programs; the dynamic load function library can run in the program Dynamic loading at all times. In fact, dynamic function libraries are not another library function format, and the dynamic loading function library is how the programmer is used. Behind we will explain. This document mainly refers to Program Library HOWTO, the author is luster (hwang@ustc.edu), any non-commercial purposes, release this document, but please keep the author information and copyright statement. This document is first published at www.linuxaid.com.cn. 2. Static Library Static Function Library is actually a collection of a normal target file. Generally speaking, ".a" as the suffix of the file. You can use AR this program to generate a static function library file. Ar is Archiver abbreviation. The static function library is now not used so much, mainly because there is a lot of advantages compared to the sharing function library. Slowly, everyone likes to use the shared function library. However, in some venue static function libraries are still in use, keep some compatibility with some of the programs, and it is relatively simple. The static library function allows the programmer to set the program LINK without re-compiling the code, saves the time to recompile the code. However, in front of this fast computer today, the re-compilation of the general procedure will not take much time, so this advantage is not as obvious as it. The static function library is still very useful for developers. For example, you want to use the functions you provide to others, but you want to keep your function's source code, you can give others a static function library file. In theory, the code generated by the static library function using the ELF format can run in a program running speed than the program that uses the shared function library (or dynamic function library), about 1-5%. Create a static function library file, or add a new target code to an existing static function library file, you can use the following command: ar rcs my_library.a file1.o file2.o this example is the target code file1.o And file2.o Add to my_library.a. In this library file, create a new file if MY_LIBRARY.A does not exist. When you create a static library function with the AR command, there are other options that can be selected, you can participate in the use of AR. Not detailed here. Once you have created a static library, you can use it. You can use it as part of your compilation and connection to generate your executable code. If you use GCC to compile to generate an executable code, you can specify this library function with the "-l" parameter. You can also use LD to use its "-l" and "-l" parameter options. Specific usage, you can refer to INFO: GCC.

3. Shared functions library (http://bbs.shareunion.net/redirect.php?fid=19&tid=68880sfoto=nextoldset) The function in the shared log library is loaded when an executable is started. If a shared function library is installed normally, all programs can automatically load the functions in the latest library when re-run. For Linux systems, there are more implementable features: o Upgrade the library but still allows the program to use the old version of the library. o Overwrite a particular library or the function specified in a particular library or library when performing a particular program. o You can modify these function libraries during the library function. 3.1. Some conventions If you want to write a shared log library support all useful features, you must follow a range of conventions during the process of writing. You must understand the difference between the different names of the library, such as the difference between its "Soname" and "Real Name" and how they interact. You also need to know what location you should put these library functions in your file system. Let's take a look at these problems. 3.1.1. Naming of shared libraries Each shared function library has a special name, called "Soname". Soname Name Naming must be a prefix as a "lib", then the name of the library, then ".so", and finally the version number information. However, there is a special case, that is, very lateral C library functions are not named in Lib. Each shared function library has a real name ("Real Name"), which is a file containing the true library function code. The real name has a primary version number, and a release version number. The last release version number is optional, but no. The main version number and the release version allow you to know what version library function is installed. In addition, there is another name that is the name of the function library required when the compiler is compiled. This name is a simple Soname name without any version number information. The key to manage sharing functions libraries is to distinguish these names. When the executor needs to list these shared library functions in their own programs, it can be used with Soname; in turn, when you want to create a new shared log library, you have to specify one A specific file name containing very detailed version information. When you install a new version of the function library, you can copy these function library files to some specific directories, running LDConfig. LDConfig Checks the existing library file, then create Soname's symbols to the real library, and set the buffer file for /tc/ld.so.cache. We discussed this later. LDConfig does not set the name of the link, the usual practice is to complete the establishment of this link name during the installation process. Generally, this symbolic link is simple to point to the latest Soname or the latest version of the library file. It is best to point this symbolic link to Soname, because you can automatically use the new version of the new version of the function Culler after you upgrade your library function. Let's see: /usr/lib/libreadline.so.3 is a complete complete Soname, LDConfig can set a symbol to link to other real library files, for example /usr/lib/libreadline.so . 3.3.0. At the same time, there must be a link name, such as /usr/lib/libreadLine.so is a symbolic link pointing to /usr/lib/libreadline.so.3.3.1.2. The location sharing function library file of the function library file in the file system must In some specific directories, these function libraries can be used correctly through the system's environment variable settings.

Most of the source code development procedures follow some of the GNU, we can see the Info Help file to get the instructions, the location of Info information is: Info: Standards # Directory_variables. GNU standards recommend that all library files are placed in the / usr / local / lib directory and suggesting that the executor is placed in / usr / local / bin directory. This is some habits, which can be changed. File System Hierarchical Standard FHS (FileSystem Hierarchy Standard) (http://www.pathname.com/fhs) specifies that most of the library files in a release package should be installed in the / usr / lib directory, but if a Some libraries are loaded when the system is started, then put in the / lib directory, and those that are not part of the system itself are placed under / usr / local / lib. There is no essential conflict in the two paths above. The standard proposed by the GNU is primarily for developers to develop source code, while FHS suggestions are for the path to the release. The specific location information can be seen in /etc/ld.so.conf inside the configuration information. 3.2. These libraries use the binary executable of the ELF format to start a program loader in a GNU GLIBC-based system, including all Linux systems. For Linux systems, this Loader's name is /Lib/ld-linux.so.x (X is the version number). After this Loader is started, the shared function library of all other other programs that will be loaded will be used. What are the shared functions libraries in the directory? These defaults are in /etc/ld.so.conf files, we can modify this file, join our own special path requirements. Most redhat series issued bag /etc/ld.so.conf file does not include / usr / local / lib, if there is no such directory, we can modify /etc/ld.so.conf, manually add This entry. If you want to override some of the functions in a library, replace them with your own function, while keeping other functions in the library, you can join the library you want to replace in /etc/ld.so.preload (. o End file), these preloading library functions will have priority to load. Search all directories when the program is started, it is clear that the efficiency is very efficient, so the Linux system actually uses a high-speed buffering approach. LDConfig reads the /etc/ld.so.conf related information by default, then set the appropriate symbolic link, then write a cache to /etc/ld.so.cache this file, and this /etc/ld.so .cache can be used by other programs. This approach greatly improves the speed of the access function library. This requires that each time you add a dynamic loaded library, you have to run LDConfig to update this cache. If you want to delete a library, or if you modify a library, you must re-run LDConfig to update. This cache. The usual package manager is running LDConfig when installing a new function library. In addition, FreeBSD is different from the Cache file. FreeBSD's Elf Cache is /var/run/ld-elf.so.hints, and A.out's cache is /var/run/ld.so.hints. They are also updated by ldconfig. 3.3. Various environment variables of environment variables control some key processes. For example, you can temporarily perform a different library for your specific programs.

In the Linux system, usually the variable ld_library_path is to specify the library lookup path, and this path is usually found before the lookup of the standard path. This is useful, especially when commissioning a new function library, or when using a fertilizer standard library in a special occasion. Environmental Variable LD_PRELOAD lists all library files, functions, and /etc/ld.so.preeload, which need to be prioritized in all shared functions libraries. These are all /lib/ld-linux.so this loader is implemented. It is worth mentioning that ld_library_path can work normally under most UNIX-LINKE systems, but not all systems can be used, for example, in the HP-UX system, the variable of shlib_path, and use it under AIX LibPath variable. LD_LIBRARY_PATH often uses a lot of use during development and debugging, but should not be modified by a normal user during the installation process, everyone can refer to http://www.visi.com/~barr/ldpath.html, here there is A document specifically introduces why this variable is not used by ld_library_path. In fact, more environment variables affect the process of transferring procedures, their names are usually taking LD_ or RTLD_ head. Most of these environmental variables are not full, usually speaking, if you want to truly understand their usage, it is best to read the source code of Loader (which is part of GCC). Allows the user to control dynamic links The library involves the setuid / setgid this function if special features need. Therefore, GNU Loader usually limits or ignores users using SETUID and SETGID for these variables. If the Loader uses the setuid or setgid if the associated environment variable determination program is used, if the UID and EUID are different, or the GID and EGID are the same, then the loader assumes that the program has already used SetUID or setgid, then the big limiter Control the permissions of this old link. If you read the GNU GNU GLIBC library function source, you can clearly see this, especially we can see two files of ELF / RTLD.C and SYSDEPS / Generic / DL-sysDep.c. This means that if you make the UID and GIDs are equal to EUID and EGID, then these variables can completely start. 3.4. Create a shared function library (http://bbs.shareunion.net/redirect.php?fid=19&tid=68878&goto=Nextoldset) Now we start learning how to create a shared log library. In fact, it is very easy to create a shared function library. First create an Object file, this file will join the GCC-FPIC parameter command to add to the shared log library. The PIC means "position independent code". Here is a standard format: gcc -shared -wl, -soname, your_soname -o library_name file_list library_list Next, you create two Object files (AO and BO), then create a shared function including AO and BO Library. The "-g" and "-wall" parameters are not required in the example.

GCC-FPIC-G -C-Wall A.CGCC-FPIC -G -C -WALL B.CGCC -SHARED -WL,-Soname, LiblustersTUFF.SO.1 -O LiblustersTUFF.SO.1.0.1 AO BO -LC below It is some places you need to pay attention to: • Don't use -FOMIT-FRAME-POINTER This compilation parameter unless you have to do this. Although the library obtained by using this parameter is still available, this makes the debugger almost useless and cannot track debugging. · Use -fpic to generate code instead of -fpic. · In some cases, use GCC to generate an Object file, you need to use "-wl, -export-dynamic" option parameters. Typically, the symbol table of the dynamic function library contains the symbols of these dynamic objects. This option is added to the dynamic symbol table when creating a file in the ELF format. A more detailed description can be obtained with reference to the help of the LD. 3.5. Installing and Using Shared Releases Once you have a shared log library, you also need to install it. In fact, a simple way is to copy your library file to the specified standard directory (such as / usr / lib), then run LDConfig. If you don't have the permissions to do this, for example, you can't modify the / usr / lib directory, then you have to implement these function libraries by modifying your environment variables. First, you need to create these shared functions libraries; then, set some must-have symbolic links, especially from Soname to true library file symbolic link, simple method is to run LDConfig: ldconfig -n directory_with_shared_libraries, then you can set you LD_Library_Path This environment variable, it is a collection of a comma-separated path, which can be used to indicate the search path of the shared function library. For example, using bash, you can start a program MY_PROGRAM: LD_Library_path =.: $ Ld_library_path my_program If you need a heavy-duty section function, you need to create an Object file that contains a function you need to be overloaded, then set LD_PRELOAD Environment variable. Usually you can upgrade your library, if an API changes, the creation of the library changes Soname. However, if a function is upgraded to a function library and keeps the original Soname, you can copy the old version of the library to a location and rename this file (for example, using the original name, then add .orig Suffix), then create a small "wrapper" script to set this library function and related things. For example, the following example: #! / Bin / sh export ld_library_path = / usr / local / my_lib: $ ld_library_path exec /usr/bin/my_program.orig $ * We can see the shared function library for a program by running LDD.

For example, you can see the LS this utility to use the library: LDD / BIN / LS LIBTERMCAP.SO.2 => /Lib/LIBTERMCAP.SO.2 (0x4001C000) libc.so.6 => /lib/libc.so. 6 (0x40020000) /LIB/ld-Linux.so.2 => /Lib/ld-linux.so.2 (0x40000000) usually I can see a list of Soname, including paths. In all cases, you can at least see two libraries: · /lib/ld-linux.so.n (N is 1 or more, generally at least 2). This is this library that loads all other shared libraries. · Libc.so.n (n should be greater than or equal to 6). This is a C language function library. It is worth mentioning that don't run the LDD command on the program you don't trust. Inside the LDD's Manual, LDD is to set this program by setting certain special environment variables (for example, for ELF objects, setting ld_trace_loaded_objects) and then runs this program. This is likely to make a program may make LDD to perform some unexpected code, and an unsafe hidden danger. 3.6. Incompatible Library If a new version of the library is incompatible with the old version of the binary library, Soname needs to change. For C language, there are four basic reasons to make them difficult to compatibility on binary code: o. The line of the function changes, so that it may be unqualified with the first definition. o. The output data item changes. o. Some output functions delete. o. The interface of some output functions changes. If you can avoid these places, you can keep your library compatible on binary code, or, you can make your program's application binary interface (ABI: Application Binary Interface) is compatible. 4. Dynamically loaded Library Dynamically Loaded (DL) Libraries Dynamic Libraries Dynamical Loaded (DL) libraries is a class of libraries that can be loaded at any time during the program run. They are particularly suitable for loading some modules and plugin extension modules in a function because it can be loaded when the program needs a PLUGIN module. For example, a Pluggable Authentication Modules (PAM) system is to use dynamically loaded function libraries to enable administrators to configure and reconfigure authentication information. Under the Linux system, the DL function library does not have a special difference in format, and we mention it before, it is created, it is a standard Object format. The main difference is that these function libraries are not loaded when the program links or when started, but through an API to open a library, find a symbol table, handle errors, and shut down the library. Usually in the C language environment, you need to include

This header file. The functions used in Linux are the same as the Solaris, which are DLPOEN () API. Not all platforms were used to use the same interface, such as HP-UX using the SHL_LOAD () mechanism, while the Windows platform uses another other call interface. If your purpose is to make your code have strong portability, you should use some Wrapping function libraries, such a Wrapping Library hides the interface difference between the different platforms. One way is to use the support of the dynamic loading module in the GLIBC library, which uses some potentially dynamic load function library interfaces to enable them to use it. Specifically, you can refer to http://developer.gnome.org/doc/api/glib/glib-dynamic-loading-of-modules.html. Another way is to use libltdl, is part of GNU Libtool, you can further refer to CORBA related information . 4.1. DLOPEN () DLOPEN function Opens a library and prepares for use later. C language prototype is: void * dlopen (const charg); if the file name filename is beginning with "/", that is, using the absolute path, then DLOPNE uses it directly, not find some environment variables Or the directory where the system set the library. Otherwise, DLOPEN () will find the library file according to the order below: 1. The path to the environment variable LD_Library indicates. 2. /etc/ld.so.cache List list. 3. / lib directory, then / usr / lib. However, some old A.out's Loader uses the opposite order, which is the first to check / usr / lib, then / lib. Dlopen () function, the value of the parameter flag must be RTLD_LAZY or RTLD_NOW, RTLD_LAZY meaning resolve undefined symbols as code from the dynamic library is executed, and the meaning of RTLD_NOW is resolve all undefined symbols before dlopen () returns and fail if this Cannot be done '. If there are several function libraries, there are some dependencies, such as X dependence Y, then you will first load those dependent functions. For example, load Y and then load X. The return value of the DLOPEN () function is a handle, then the following functions are further operated by using this handle. If you open the failed dlopen (), you return a NULL. If a library is opened multiple times, it returns the same handle. If there is an output function name in a library to _init, then _init will be executed before the DLOPEN () function returns. We can use this function to do some initialization work in my library. We will continue to discuss this problem later. 4.2. DLError () By calling the DLERROR () function, we can get the last call DLOPEN () (), DLSYM (), or DLClose () error message. 4.3. Dlsym () (http://bbs.shareunion.net/redirect.php?fid=19&tid=68876&goto=nextoldset) If you load a DL function library without usage, it is certainly impossible, use a DL The most important function of the library is DLSYM (), which looks up a given symbol in a library that has been opened.

This function is defined as follows: void * dlsym (void * handle, char * symbol); the parameter handle in the function is the handle returned by DLOPEN, and Symbol is a string ending with NIL. Returns NULL if the DLSYM () function does not find Symbol you need to find. If you know that a Symbol value is not null or 0, then it is very good, you can determine if the Symbol lookup is exist according to this return result; however, if a Symbol value is null, then this judgment is There is a problem. The standard judgment method is to call DLERROR (), clear the previously possible errors, and then call DLSYM () to access a Symbol, then call DLERROR () to determine if an error occurs. A typical process is as follows: DLERROR (); / * Clear error code * / s = (actual_type) DLSYM (Handle, Symbol_being_searched_for); if ((Err = DLERROR ())! = Null) {/ * handle error, The Symbol Wasn't Found * /} else {/ * symbol found, ITS value is in s * /} 4.4. DLClose () DLOPEN () function The anti-process is the dlclose () function, the dlclose () function is powered off a DL function library . The DL function library maintains a counter-use counter. When the DLClose is called, the count of the counter is reduced. If the counter is 0, the real release is true. When you really release, if you have a _fini () function in the function library, you will automatically call the _fini () this function, do some necessary processing. DLClose () returns 0 means success, other non-zero represents an error. 4.5. DL Library Example The following is an example. In the example, the Math library is transferred, then print the 2.0 cosine function value. Each time it is checked in the example.

It should be a good example: #include #include #include int main (int Argc, char ** argv) {void * handle; double (* cosine) (double) (Double); char * error; handle = DLOPEN ("/ lib / lib / lib / lib / .sso.6 ", RTLD_LAZY); if (! Handle) {FPUTS (DLERROR (), stderr); exit (1);} cosine = DLSYM (Handle," COS "); if ((Error = DLError ()) ! = Null) {FPUTS (Error, stderr); exit (1);} Printf ("% f", (* cosine) (2.0)); dlclose (Handle);} If this program name is foo.c, then Compile: gcc -o foo foo.c-ldl 5.1. Nm Command nm command can list symbolic tables in a library file. It works for static functions libraries and shared libraries. For a given library, the nm command can list all symbols defined in the function library, including the values ​​and types of each symbol. It is also possible to give this function (symbol) in the original program, how many lines are defined, but this must be required to compile the "-l" option when the library is compiled. About the type of symbol, here we discuss more. The type of symbol is displayed in the form of a letter. The lowercase letter indicates that the symbol is local (Local), and the uppercase letter indicates that this symbol is global, externel. In general, the type has several: t, d, b, u, w. The respective meanings are as follows: T represents the general variable symbols defined in the code segment; D represents the data segment initialized during the period; b represents the initialized data segment; u means that it is not defined, in this library is used, but in other libraries Symbols defined in; W, WEAK abbreviation, indicating that there is also a definition of this symbol in other libraries, and other symbols definitions can override this definition. If you know the name of a function, you don't know what this function is defined in what library, then you can use the "-o" option and grep command to find the name of the library. The -o option makes each line of display have this function library file name. For example, you have to find "COS" this is defined where you are defined, can be used below the following command: nm -o / lib / * / usr / lib / * / usr / lib / * / * / usr / local / lib / * / * / usr / local / lib / / * 2> / dev / null | Grep 'COS $' About NM More detailed usage We can refer to the INFO document, location is info: binutils # nm. 5.2. Special functions _init and _fini library have two special functions, _init and _fini, which we have said before. It is mainly used to initialize the function library and close, we can put the code you think in these two functions, which is performed when the function library is loaded and released.

Specifically, if there is a function library in a library "" _init "function output, then open this function library in the first time, or just simply as a shared function library is opened, _init function is Automatic call execution. The correspondence with it is the _fini function, when a program calls DLClose () release the reference to this library, if the reference counter is 0, or this function library is a general sharing function When the library is used and the program is used normally, _fini will be called executed. C language defines their prototypes as follows: void _init (void); void _fini (void); When using the GCC Compile Source Program as ".o" file, you need to add a "-nostartfiles" option. This option makes the C compiler without linking the boot function in the launch function library of the system. Otherwise, you will get a "multiple-definition" error. 5.3. Shared functions can also make the scripts GNU's Loader to write a library using a special format scripting language. This is also useful for situations where you need to indirectly contain other function libraries. For example, the following is an example of /usr/lib/libc.so: / * GNU LD Script Use The Shared Library, But Some Functions Are Only in The Static Library, SO Try That Secondarily. * / Group (/ lib / libc. SO.6 /usR/LIB/Libc_nonshared.a) More information can refer to the script section of the LD link in the TexInfo document. General information can also be referred to: Info: LD # options and info: ld # commands, you can also refer to INFO: LD # Option Commands. 5.4. GNU Libtool If you are being compiled, you can use GNU Libtool to create and install this function library using GNU Libtool. GNU LibTool is a typical script supported by a library. LibTool hides the responsibility of using a portable function library. LibTool provides a portable interface to create an Object file, a link function library (static or shared), and install these libraries. It also contains libltdl, a portable dynamic function library to transfer Wrapper's Wrapper. More detailed discussion, you can see at http://www.gnu.org/software/libtool/manual.html. 5.5. Deleting some symbols in a production file, many symbols are included for DEBUG, which takes up a lot of space. If there is not enough space, and these symbols may not be needed, you can delete some of them. The best way is to first generate the Object file you need, then debug and test something you need. Once you are fully tested, you can use Strip to delete some unwanted symbols. The strip command allows you to easily control what symbols are deleted, but what symbols are retained. Strip's specific usage can refer to its help file. The additional method is to use the option "-s" and "-s" of the GNU LD, "-S" will delete some Debugger's symbols, and "-s" is deleted all symbolics. Usually we can add such parameters "-wl, -s" and "-wl, -s" to achieve this purpose in GCC. (Http://bbs.shareunion.net/redirect.php?fid=19&tid=68874&goto=nextoldset) Abstract: Here are some examples, we use three functions libraries (static, shared, and dynamically loaded functions) Library.

The file libhello.c is a library, libhello.h is its header file; demo_use.c is a libhello library. Script_static and script_dynamic demonstrates how to use a library in static and sharing, while the following demo_dynamic.c and script_dynamic indicate how to use it in a dynamically loaded function library. 6. More Examples Here are some examples, in example, we use three function libraries (static, shared, and dynamically loaded libraries). The file libhello.c is a library, libhello.h is its header file; demo_use.c is a libhello library. Script_static and script_dynamic demonstrates how to use a library in static and sharing, while the following demo_dynamic.c and script_dynamic indicate how to use it in a dynamically loaded function library.

6.1. File Libhello.c / * libhello.c - DemonStrate Library Use. * / #Include void Hello (Void) {Printf ("Hello, Library World.");} 6.2. File Libhello.h / * libhello.h - DemonStrate Library Use. * / void Hello (Void); 6.3. File Demo_use.c / * Demo_use.c - Demonstrate Direct Use of the "Hello" Routine * / #include "libhello.h" int main (void) {Hello (); RETURN 0;} 6.4. File script_static #! / Bin / sh # static library demo # create static library's object file, libhello-static.o. # I'm using the name libhello-static to clearly # Differentiate The Static Library from the # Dynamic Library Examples, But you don't need it # "-static" in the names of your # Object files or static libraries.gcc-static.o libhello.co.io libhello-static.o libhello.c # Create static library.ar rcs libhello-static.a libhello-static.o # at this point we could just copy libhello-static.a # Somewhere else to use it it. # For demo purposes, we'll Just Keep The Library # in the current directory # Compile demo_use program file.gcc -Wall -g -c demo_use.c -o demo_use.o # Create demo_use program;.. ".". -L causes to be searched during # creation of the program Note that this command causes # the relevant object file in libhello-static.a to be # incorporated into file demo_use_static.gcc -g -o demo_use_static demo_use.o -L. -lhello-static # Execute the program ../ demo_use_static 6.5. File script_shared #! / bin / sh # shared library demo # create shared library '

S Object File, Libhello.o.gcc-fpic -wall -g -c libhello.c # create shared library. # use -lc to link it against c library, since libhello # depends on the c library.gcc -g -shared -Wl, -soname, libhello.so.0 -o libhello.so.0.0 libhello.d # at this point we could just copy libhello.so.0.0 Into # Some Directory, Say / USR / local / lib. # Now We need to call ldconfig to fix up the symbolic links. # Set up The Soname. We could Just Execute: # ln -sf libhello.so.0.0 Libhello.so.0 # But let's let ldconfig figure it out ?/sbin/ LDConfig -n. # set up the linker name. # in a more sophistated setting, we'd need to make # Sure, # and if so, check if it should stay or not.ln - sf libhello.so.0 libhello.so # compile demo_use program file.gcc -wall -g -c demo_use.c-c g _ o. # Create Program Demo_use. # The -l. causes "." to be search during code # Of The Program; Note That Does Not Mean That "." # Will Be Searched WH en the program is executed.gcc -g -o demo_use demo_use.o -L. -lhello # Execute the program. Note that we need to tell the program # where the shared library is, using LD_LIBRARY_PATH.LD_LIBRARY_PATH = "." ./ . demo_use 6.6 File demo_dynamic.c / * demo_dynamic.c - demonstrate dynamic loading and use of the "hello" routine * / / * Need dlfcn.h for the routines to dynamically load libraries * / #include #include #include / * Note That We don't have to include "libhello.h". However, We do need to specify, we need to specify a type tria Will Hold The Value We're Going to Get from DLSYM (). * / / * The Type "Simple_Demo_function"

转载请注明原文地址:https://www.9cbs.com/read-132077.html

New Post(0)