In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to call dll&. So library under Linux, has certain reference value, interested friends can refer to, hope you can learn a lot after reading this article, let the editor take you to know about it.
Dll is the abbreviation of Dynamic Link Library. DLL is a library that contains code and data that can be used simultaneously by multiple programs.
{void * handle=dlopen (". / libdemo4.so", RTLD_LAZY); void (* fun) (int) = dlsym (handle, "diamond"); fun (5); dlclose (handle);} the principle of loading using libdl.so dynamic libraries
The search for functions in the dynamic library has been encapsulated into a library libdl.so dlopen opens a dynamic library dlsym finds a function dlclose closes the dynamic library / / dlerror returns an error
Note that dynamic libraries can be executed, static libraries cannot be executed, but dynamic libraries do not have main and cannot be executed independently. Dynamic libraries are not connected as part of the program. Dynamic library files must be required when the program is executed.
The dynamic library ldd that the ldd viewer needs to call can only view executable files. Readelf-h looks at the execution header. Nm looks at the function symbol 3 in the library. Compilation of dynamic library 3.1. Compile-c-fpic (optional) 3.2. Connect-shared 4. Use dynamic library gcc code dynamic library file name gcc code-l library name-L dynamic library path
Standard naming convention: lib library name.so lib library name.a
-l library name-the path where the L library is located is Dashankeng: 4.1. How does the executor load the dynamic library? 4.2. Dynamic libraries are not part of the execution program, so why do connections need to specify dynamic libraries and directories? The connector needs to determine the location of the function in the dynamic library
Loading of dynamic library: 1. Find the dynamic library 2. Load dynamic library into memory 3. Mapping to the user's memory space the system looks up the dynamic library rule: / lib / usr/lib to the path specified by the environment variable LD_LIBRARY_PATH
three。 Compilation of static library 1. Compilation process (* .an achieve) 1.1. Compiled into an object file-static optional gcc-c-static code file. C
1.2. Archived as static library ar tool ar-r-t ar-r static library file archived file
Nm tool (see function symbol table) nm static library or dynamic library or object file or execution file 1.3. Use static libraries gcc code static libraries
Crystallization steps:
1. Function and other code encapsulated binary compiled archive file 2.ar archiving mode library mode 3. Compiled programs run without relying on libraries. The library compiles the link as part of the program.
4. File collection (filing) 5. Note the library naming rules: lib library name. A. The main version number. Minor version number. Batch number lib library name.a library usage rules-l library name-L library directory
Thank you for reading this article carefully. I hope the article "how to call dll&. So Library under Linux" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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.