当前位置:网站首页>Creation and use of QT dynamic link library

Creation and use of QT dynamic link library

2022-04-23 18:15:00 Talent、me

Purpose

Compiling the source file into a dynamic library is to compile the source code .cpp While keeping the code confidential ,
Subdivide each function into modules , It is convenient for later sorting and other people to call directly .

stay Qt Creator Create a dynamically linked library project

Steps are as follows :
 Insert picture description here
Let's focus on , If you want to put the source code .cpp Sub assemble into dynamic library , And the source code uses Qt Related libraries , For example, a custom encapsulated Messagebox Dialog interface , Then you need to choose Widgets perhaps Core.
 Insert picture description here
 Insert picture description here
Always choose the next step , Then determine ,Qt Creator The following project will be generated .
 Insert picture description here
For verification purposes , I only wrote a member function void test();
Then click compile... In the lower left corner , This pop-up window will pop up , This pop-up window can be ignored .

 Insert picture description here
Then the compiled dynamic library will appear in the compiled target path .
 Insert picture description here
To this step , Create success .

Using dynamic libraries

stay Qt In the project xxx.pro Add header file path and library file path to the file
INCLUDEPATH +=./
LIBS += -L/home/hy/Demo/testlibso/lib -lmyLibDemo

Then add two header files about the dynamic library in the project
 Insert picture description here
You can successfully use the dynamic library .

版权声明
本文为[Talent、me]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210610471456.html