Dynamic library generation and use in Linux (simple)

Source: Internet
Author: User

In the past two days, the customer asked how to use the dynamic library in the issued SDK, but he had not done it before. From yesterday till now, he finally got it done.

Here, we only describe the simple method.

Reference URL:

Http://www.oschina.net/question/54100_32476

 

The dynamic library is compiled as follows:

Gcc-FPIC-shared car. C ship. C-o libtranic. So

It is important that you have a-shared option to specify the dynamic library to be generated.

The header file of the dynamic library is the same as the common. h file, so no special requirements are required.

 

The dynamic library is used as follows:

Gcc-O test. c libtranic. So

Add this dynamic library at the end of the compilation item. If compilation is divided into compilation and link, it should end with the link.

Note: When I use the-L option, errors are always prompted.

Here is just a simple method. To illustrate the problem, there may actually be a lot of applications that won't be used in this way, but they are handled in a "regular" way, for example, to place a dynamic library to the lib directory of the system, we will not discuss it here

 

 

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.