What are the static and dynamic libraries of Cmake in C++?
This article mainly shows you "the construction of Cmake in C++ static library and dynamic library is what", the content is easy to understand, clear, hope to help you solve their doubts, the following let the editor lead you to study and learn "what is the construction of Cmake static library and dynamic library in C++" this article.
The difference between static Library and dynamic Library
1. Static libraries generally have the extension ".a" or ".lib"; dynamic libraries generally have the extension ".so" or ".dll".
2. The static library will be directly integrated into the target program at compile time, and the successfully compiled executable files can be run independently.
3. The dynamic library will not be put into the connected target program at compile time, so the executable file cannot be run alone.
Build an example
Create a new project cmake02 with the following directories
Content in hello.h
# ifndef HELLO_H#define HELLO_H void HelloFunc (); # endif
Content in hello.cpp
# include "hello.h" # include using namespace std; void HelloFunc () {cout