5. Understanding what is called dependency---dynamic link library

Source: Internet
Author: User

Foreplay:

Have a chat today. Dynamic Link library!

Windows:dynamic? Link? Library (DLL), suffix? Xxx.dll!

Linux: is GKFX? Library. What is the suffix? xxx.so!

The simple idea is to encapsulate it as a class library, and other programs can be called dynamically.

Versatility, encapsulation, after all, some code do not want others to see.

Ps: Detailed explanation http://bbs.chinaunix.net/thread-1281954-1-1.html

Body:
    1. Compile the source file. C into a dynamic-link library. So

      GCC-shared Me.c-o libme. so

      The main program automatically adds Lib and. So suffixes based on the header file name to find the dynamic link library, which is written at compile time.

    2. Compile

      Federated compilation:

      GCC fatsnake.c me.c-o fatsnake

      ?

      (1) compile with dynamic link library (you don't have to make all the source files)------------------------manually specify where my dynamic link library is

      GCC –L /root/- l me fatsnake.c-o Fatsnake

      -L Dynamic Link Library folder location

      The library name of the-l dynamic-link library (removes the front lib and. So is the library name)

      (2)ldd Main program name view dependency

      ???? LDD Fatsnake

      ?

      Q: The reason for the failure is that the operating system cannot find libme.so???

      A: In fact, like Linux and Windows, there is a system library folder similar to System32. All kinds of public libraries are put in this

      There are two folders in CentOS that are similar to Windows that hold a common library

      /lib Kernel level

      /usr/lib User System level

      The/USR/LIB64/64-bit system only

You're going to have to put your good library out of your mind. Here's a temporary demonstration. Put in the specified public library

(3) Copy to Shared Library folder: Copy the link library to the development folder

???? CP source File destination folder

???? Cp/root/libme.so/lib

(4) Reload the link library

Ldconfig

Explanation: http://blog.163.com/cn_prince/blog/static/638790120078289157270/

The main program is now associated with the link library.

?

Ps: The libme.so file in Lib is deleted, and the file runs failed! Dynamic link libraries cannot be deleted, otherwise dependencies cannot be found

????

?

End:

Today is a bit tired, fitness squat legs tired bar! A will chew book, Wash and sleep!

5. Understanding what is called dependency---dynamic link library

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.