Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the static and dynamic libraries of Cmake in C++?

Shulou Source: shulou.com Published: 2022-06-01 05:02:18 09月22日 Update

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

Tags: Dynamic static file content path version directory variable name link clocking keyword environment target article search compile binary and at the same time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information OPPO Reno vpn NVidia MySQL