Home > Article > System Tutorial > In-depth analysis of centos' dynamic link library joint compilation technology
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!