Home > System Tutorial > LINUX > In-depth analysis of centos' dynamic link library joint compilation technology

In-depth analysis of centos' dynamic link library joint compilation technology

WBOY
Release: 2024-01-10 13:26:39
forward
1286 people have browsed it

What is a dynamic link library

On Windows it is dynamic linklibrary (DLL), suffix? xxx.dll

It is Shared Library on UNIX or Linux. The suffix is ​​xxx.so

Compile the file into a dynamic link library in .so format

gcc -o libme.so wso.c -shared

Compile wso.c into libme.so and the library name is me

lib so is the prefix and suffix

Joint compilation

gcc -L /root/myc/ -l me ws.c -o newws

-L Folder location of dynamic link library

-l The library name of the dynamic link library (remove the first lib and .so is the library name)

Next you will find that the compilation is successful, but the operation still fails

The reason for failure is that the operating system cannot find it

In fact, Linux, like Windows, has a system library folder similar to system32. Various public class libraries are placed here

CentOS has two folders that store public libraries that are very similar to windows

/lib kernel level

/usr/lib User system level

/usr/lib64/ Only available on 64-bit systems

You have to make a good library, it doesn’t matter if you put it in a random way

Solution

Copy the SO file we made to the public library (cp command)

Then execute ldconfig (the dynamic library is cached. If new things are added, the cache needs to be updated again)

Run newws successfully

The above is the detailed content of In-depth analysis of centos' dynamic link library joint compilation technology. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:jb51.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template