With the development of Linux over the past decade, Linux has become closer and closer to Microsoft. Do you know about Linux? Are you an application of Linux? Here we will explain the implicit calls of inux dynamic libraries, which will play a role in learning the implicit calls of Linux dynamic libraries.
The implicit call means that the library file name does not appear in the code, that is, the code and
The code for calling the static library is similar.
1. Compile the test file
- // Main. c test the program implicitly called by the dynamic library
- # Include "myalib. h" // include the function header file. Otherwise, an error is reported during compilation.
- Int main (int argc, char * argv [])
- {
- Test ();
- Return 0;
- }
2. Compile the test program. Similar to the static library, add the path of the header file to the-I parameter.
Gcc-I/root/exercise-o main. o-c main. c
A main. o file is generated.
3. Generate a test program
Gcc-o main-L/root/exercise main. o-ltest
A main file is generated.
4. Execute the test program
./Main
The prompt is displayed.
./Main: error while loading shared libraries: libtest. so: cannot open shared object file: No such file or directory.
This is because the path of the dynamic library is not known when the program runs, so it cannot be found. The above is an explanation of the implicit call of the Linux dynamic library.
- Configuration notes: configure the DNS server in Linux
- How to display Chinese Characters in RedHat Linux 5
- How to disable SELinux in Redhat Enterprise Linux
- Install the KDE package in Linux
- Redhat Linux Remote Desktop configuration