Example Analysis of Joint compilation dynamic Link Library in centos
This article shares with you the content of the sample analysis of joint compilation of dynamic link libraries in centos. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
What is a dynamic link library
On Windows is dynamic linklibrary (DLL), suffix? Xxx.dll
On UNIX or Linux, it is Shared Library. 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 a libme.so library named me
Lib so is a prefix and suffix
Joint compilation
Gcc-L / root/myc/-l me ws.c-o newws
Folder location of-L dynamic link library
-l the name of the dynamic link library (excluding the leading lib and .so is the library name)
Then you will find that the compilation is successful, but the run still fails.
Failed because the operating system could not find it.
In fact, Linux, like windows, has a system library folder similar to system32. All kinds of public class libraries are placed here
There are two folders in CentOS that hold common libraries very similar to windows.
/ lib kernel level
/ usr/lib user system level
/ usr/lib64/ 64-bit system only
It doesn't matter if you leave your library blindly.
Solution method
Copy the SO file we made to the common library (cp command)
Then ldconfig (cache the dynamic library). Add new gadgets and need to update the cache)
Run newws successfully
Thank you for reading! This is the end of this article on "sample analysis of jointly compiled dynamic link libraries in centos". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!