table of Contents
Third, the project is compiled
2. Cancel create the build directory
3, build (compile) the project
First, create a project
1. Create a project Libaray
Qt Creator into the main interface, click on New -> Libaray -> C ++ Libaray
2, Project Name
Fill in name here InitDll (just named), has since been default, the next step
3, select the language
Chinese language can be selected, recommended here do not choose Language
4. Select the compiler
QT installation of the compiler will be selected, where the recommended compiler on Select All
5, select the version control
If the project uses Git or svn select, where this is not selected by default, click Finish
Second, the writing test code
1, file directory
After creating the Library Project, the project will generate the following files
2, written in .h files
Here initdll.h file can be understood as Java interfaces
#ifndef INITDLL_H
#define INITDLL_H
#include "InitDll_global.h"
class INITDLL_EXPORT InitDll
{
public:
InitDll();
QString print(QString str);
int add(int a,int b);
};
#endif // INITDLL_H
3, write .cpp file
Here .cpp file can be understood as the realization of Java classes
#include "initdll.h"
#include <QString>
InitDll::InitDll()
{
}
QString InitDll::print(QString str)
{
return str;
}
int InitDll::add(int a, int b)
{
return a+b;
}
Here is a tip, the mouse to select the method name, pressed Alt and Enter keys can be quickly generated implementation of the method body
Third, the project is compiled
1, view the file directory
Right-click the project in the file, select Show in explorer, you can quickly open directory project under Windows
We can see before compiling only five documents, namely .cpp, .h, .pro, .pro.user, _global.h file
2. Cancel create the build directory
The main interface click on the project, click Shadow build build directory check box to remove the check
Remove the tick will compile the files generated in the current directory project
Otherwise, the directory will be created automatically compile a file stored compiled
3, build (compile) the project
After returning to the formula bar, right-click the project, click on the building (constructed is actually a compilation of the meaning)
4, view the compiled file
After you've built, open directory project, the project found inside a few more documents
Compiled mainly produced three documents .dll, .a, .o file
So far, Qt5.14.1 generate dynamic link library tutorial has been completed
Next, teach you how to use Qt5.14.1 mobilize a dynamic link library (.dll and .h files)