In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to use the Linux dlopen function". In the daily operation, I believe that many people have doubts about how to use the Linux dlopen function. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to use the Linux dlopen function". Next, please follow the editor to study!
Function: open a dynamic link library
Include header file: # include
Function definition: void * dlopen (const char * pathname, int mode)
Function description: the () function in dlopen opens the specified dynamic link library file in the specified mode and returns a handle to the calling process. Use dlclose () to uninstall the open library.
Mode is opened with multiple values, and the functions implemented on different operating systems are different. Under linux, it can be divided into three categories according to their functions:
1. Parsing method
RTLD_LAZY: no parsing is performed for undefined symbols in the dynamic library until dlopen returns (valid only for function references and always parsing immediately for variable references). RTLD_NOW: all undefined symbols need to be parsed before dlopen returns. If not, NULL will be returned in dlopen. The error is:: undefined symbol: xxxx... .
2. Scope of action, which can be used in combination with parsing through "|". RTLD_GLOBAL: symbols defined in dynamic libraries can be relocated by other libraries that are subsequently opened. RTLD_LOCAL: contrary to RTLD_GLOBAL, symbols defined in dynamic libraries cannot be relocated by other libraries that are subsequently opened. If RTLD_GLOBAL or RTLD_LOCAL is not specified, the default is RTLD_LOCAL.
3. Mode of action
RTLD_NODELETE: the library is not unloaded during dlclose (), and static variables in the library are not initialized later when the library is reloaded with dlopen (). This flag is not a POSIX-2001 standard. RTLD_NOLOAD: libraries are not loaded. It can be used to test whether the library has been loaded (dlopen () returns NULL that means it is not loaded, otherwise it has been loaded). It can also be used to change the flag of the loaded library, for example, the flag of the previously loaded library is RTLD_LOCAL, and the flag will become RTLD_GLOBAL after using dlopen (RTLD_NOLOAD | RTLD_GLOBAL). This flag is not a POSIX-2001 standard. RTLD_DEEPBIND: search for symbols in the library before searching for global symbols to avoid conflicts with symbols of the same name. This flag is not a POSIX-2001 standard.
Return value:
Open error and return NULL
Successful, return library reference
Add-ldl (specify dl library) at compile time
For example
Gcc test.c-o test-ldl
At this point, the study of "how to use the Linux dlopen function" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.