HowQT PlatformGenerateStatic LibraryIs the content to be introduced in this article, mainly to learnQT PlatformAboutStatic LibraryFor more information, see the detailed description of this article. Many times we need to useStatic LibraryTo protect your core code.
Static libraries are usually provided to third parties. It is also easy to manage and maintain.
For beginners, we also look at how to generate static libraries on the QT platform.
Use the QT_Creator Wizard to generate a project
Because we have to modify the PRO, it is a pity that the wizard does not provide us with a visual generation Wizard like Carbide. Whow, Nokia has a long journey.
Let's look down:
For example, we want to generate a static library of QDll.
- // The static library pro file is as follows:
- TEMPLATE = lib
- TARGET = QDll
- QT + = coregui
- HEADERS + = \
- Qfunction. h
- SOURCES + = \
- Qfunction. cpp // method to be encapsulated
- Symbian {
- TARGET. UID3 = 0xe5afe8a2
- # TARGET. CAPABILITY + =
- TARGET. EPOCSTACKSIZE = 0x14000
- TARGET. EPOCHEAPSIZE = 0x0200000x800000
- MMP _rules + = EXPORTUNFROZEN
- CONFIG + = staticlib \
- Debug_and_release \
- Precompile_header
- }
- Qfunction. cpp
- // Use a simple addition for testing.
- IntQFunction: Add (inta, intb)
- {
- Returna + B;
- }
Build to generate the corresponding library. Congratulations! The static library has been generated
Let's see how to use the self-generated library?
Still creating a project at will
Modify the PRO file as follows:
- QT + = coregui
- TARGET = QT_DllDest
- TEMPLATE = app
- CONFIG + = libQDll
- SOURCES + = main. cpp \
- Mainwindow. cpp \
- Rlog. cpp
- HEADERS + = mainwindow. h \
- Qfunction. h \
- Rlog. h
- FORMS + = mainwindow. ui
- CONFIG + = mobility
- MOBILITY =
- Symbian {
- TARGET. UID3 = 0xe404a34b
- # TARGET. CAPABILITY + =
- TARGET. EPOCSTACKSIZE = 0x14000
- TARGET. EPOCHEAPSIZE = 0x0200000x800000
- LIBS + =-lQDll. lib // This is a static library referenced by the symbian Platform
- // Yes. The-l keyword cannot be written before it is not written.
- }
// You can directly call the following code to make the call !!
- QFunctionafun;
- intret=afun.Add(1,2);
- qDebug("ret=%d",ret);
- RLog::WriteLog("ret=",ret);
The above test code N78
Summary: how to resolveQT PlatformGenerateStatic LibraryThe contentQT PlatformUpperStatic LibraryContent learning is helpful to you!