Fully describe the implicit call of Linux dynamic library

Source: Internet
Author: User

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

 
 
  1. // Main. c test the program implicitly called by the dynamic library
  2. # Include "myalib. h" // include the function header file. Otherwise, an error is reported during compilation.
  3. Int main (int argc, char * argv [])
  4. {
  5. Test ();
  6. Return 0;
  7. }

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.

  1. Configuration notes: configure the DNS server in Linux
  2. How to display Chinese Characters in RedHat Linux 5
  3. How to disable SELinux in Redhat Enterprise Linux
  4. Install the KDE package in Linux
  5. Redhat Linux Remote Desktop configuration

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.