문제

So far I've been sticking to the following procedure: - call qmake on the project - call make

But looking at the commands Qt Creator issues for a particular project (QML plugin) I detect another procedure:

To summarize before posting the full code, for a project with 2 headers and 2 cpp files I get 2 calls to g++, followed by a call to moc, another g++, another moc and finally 2 more calls to g++, in total 7 calls, 5 to g++ and 2 to moc.

Could perhaps someone be kind enough as to explain to me why are so many calls needed and what does each one do in particular? Naturally, I do have some ideas, I see two calls to the moc and two user classes, but I still don't understand the reason for all the calls and the reason for their particular ordering.

Here is the full code (formatted to make it more readable):

arm-linux-androideabi-g++
-c
-Wno-psabi
-march=armv7-a
-mfloat-abi=softfp
-mfpu=vfp
-ffunction-sections
-funwind-tables
-fstack-protector
-fno-short-enums
-DANDROID
-Wa,--noexecstack
-std=gnu++0x
-O2
-mthumb
-Os
-fomit-frame-pointer
-fno-strict-aliasing
-finline-limit=64
-D_REENTRANT
-Wall
-Wno-psabi
-W
-fPIC
-DQT_NO_DEBUG
-DQT_PLUGIN
-DQT_QUICK_LIB
-DQT_QML_LIB
-DQT_NETWORK_LIB
-DQT_GUI_LIB
-DQT_CORE_LIB

-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\mkspecs\android-g++
-I..\plugin
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtQuick
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtQml
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtNetwork
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtGui
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtCore
-I.
-I..\..\..\Android\android-ndk-r9d\sources\cxx-stl\gnu-libstdc++\4.8\include
-I..\..\..\Android\android-ndk-r9d\sources\cxx-stl\gnu-libstdc++\4.8\libs\armeabi-v7a\include
-I..\..\..\Android\android-ndk-r9d\platforms\android-19\arch-arm\usr\include
-I.
-o plugin_plugin.obj ..\plugin\plugin_plugin.cpp

______________________________________________
arm-linux-androideabi-g++
-c
-Wno-psabi
-march=armv7-a
-mfloat-abi=softfp
-mfpu=vfp
-ffunction-sections
-funwind-tables
-fstack-protector
-fno-short-enums
-DANDROID
-Wa,--noexecstack
-std=gnu++0x
-O2
-mthumb
-Os
-fomit-frame-pointer
-fno-strict-aliasing
-finline-limit=64
-D_REENTRANT
-Wall
-Wno-psabi
-W
-fPIC
-DQT_NO_DEBUG
-DQT_PLUGIN
-DQT_QUICK_LIB
-DQT_QML_LIB
-DQT_NETWORK_LIB
-DQT_GUI_LIB
-DQT_CORE_LIB

-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\mkspecs\android-g++
-I..\plugin
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtQuick
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtQml
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtNetwork
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtGui
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtCore
-I.
-I..\..\..\Android\android-ndk-r9d\sources\cxx-stl\gnu-libstdc++\4.8\include
-I..\..\..\Android\android-ndk-r9d\sources\cxx-stl\gnu-libstdc++\4.8\libs\armeabi-v7a\include
-I..\..\..\Android\android-ndk-r9d\platforms\android-19\arch-arm\usr\include
-I.
-o myitem.obj
..\plugin\myitem.cpp

______________________________________________
moc.exe
-DQT_NO_DEBUG
-DQT_PLUGIN
-DQT_QUICK_LIB
-DQT_QML_LIB
-DQT_NETWORK_LIB
-DQT_GUI_LIB
-DQT_CORE_LIB

-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\mkspecs\android-g++
-I..\plugin -IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtQuick
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtQml
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtNetwork
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtGui
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtCore
-I.
-I..\..\..\Android\android-ndk-r9d\sources\cxx-stl\gnu-libstdc++\4.8\include
-I..\..\..\Android\android-ndk-r9d\sources\cxx-stl\gnu-libstdc++\4.8\libs\armeabi-v7a\include
-I..\..\..\Android\android-ndk-r9d\platforms\android-19\arch-arm\usr\include
-I.
-I/usr/include -I/usr/local/include
..\plugin\plugin_plugin.h -o moc_plugin_plugin.cpp

______________________________________________
arm-linux-androideabi-g++
-c
-Wno-psabi
-march=armv7-a
-mfloat-abi=softfp
-mfpu=vfp
-ffunction-sections
-funwind-tables
-fstack-protector
-fno-short-enums
-DANDROID
-Wa,--noexecstack
-std=gnu++0x
-O2
-mthumb
-Os
-fomit-frame-pointer
-fno-strict-aliasing
-finline-limit=64
-D_REENTRANT
-Wall
-Wno-psabi
-W
-fPIC
-DQT_NO_DEBUG
-DQT_PLUGIN
-DQT_QUICK_LIB
-DQT_QML_LIB
-DQT_NETWORK_LIB
-DQT_GUI_LIB
-DQT_CORE_LIB
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\mkspecs\android-g++
-I..\plugin
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtQuick
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtQml
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtNetwork
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtGui
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtCore
-I.
-I..\..\..\Android\android-ndk-r9d\sources\cxx-stl\gnu-libstdc++\4.8\include
-I..\..\..\Android\android-ndk-r9d\sources\cxx-stl\gnu-libstdc++\4.8\libs\armeabi-v7a\include
-I..\..\..\Android\android-ndk-r9d\platforms\android-19\arch-arm\usr\include
-I.
-o moc_plugin_plugin.obj
moc_plugin_plugin.cpp

______________________________________________
moc.exe
-DQT_NO_DEBUG
-DQT_PLUGIN
-DQT_QUICK_LIB
-DQT_QML_LIB
-DQT_NETWORK_LIB
-DQT_GUI_LIB
-DQT_CORE_LIB
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\mkspecs\android-g++
-I..\plugin -IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtQuick
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtQml
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtNetwork
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtGui
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtCore
-I.
-I..\..\..\Android\android-ndk-r9d\sources\cxx-stl\gnu-libstdc++\4.8\include
-I..\..\..\Android\android-ndk-r9d\sources\cxx-stl\gnu-libstdc++\4.8\libs\armeabi-v7a\include
-I..\..\..\Android\android-ndk-r9d\platforms\android-19\arch-arm\usr\include
-I. -I/usr/include -I/usr/local/include ..\plugin\myitem.h -o moc_myitem.cpp

______________________________________________
arm-linux-androideabi-g++
-c
-Wno-psabi
-march=armv7-a
-mfloat-abi=softfp
-mfpu=vfp
-ffunction-sections
-funwind-tables
-fstack-protector
-fno-short-enums
-DANDROID
-Wa,--noexecstack
-std=gnu++0x
-O2
-mthumb
-Os
-fomit-frame-pointer
-fno-strict-aliasing
-finline-limit=64
-D_REENTRANT
-Wall
-Wno-psabi
-W
-fPIC
-DQT_NO_DEBUG
-DQT_PLUGIN
-DQT_QUICK_LIB
-DQT_QML_LIB
-DQT_NETWORK_LIB
-DQT_GUI_LIB
-DQT_CORE_LIB
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\mkspecs\android-g++
-I..\plugin -IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtQuick
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtQml
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtNetwork
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtGui
-IC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\include\QtCore
-I.
-I..\..\..\Android\android-ndk-r9d\sources\cxx-stl\gnu-libstdc++\4.8\include
-I..\..\..\Android\android-ndk-r9d\sources\cxx-stl\gnu-libstdc++\4.8\libs\armeabi-v7a\include
-I..\..\..\Android\android-ndk-r9d\platforms\android-19\arch-arm\usr\include
-I. -o moc_myitem.obj
moc_myitem.cpp
del libplugin.so

______________________________________________
arm-linux-androideabi-g++
--sysroot=D:\Android\android-ndk-r9d/platforms/android-19/arch-arm/
-Wl,--no-undefined
-Wl,-z,noexecstack
-shared
-o
libplugin.so
plugin_plugin.obj
myitem.obj
moc_plugin_plugin.obj
moc_myitem.obj
-LD:\Android\android-ndk-r9d/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a
-LD:\Android\android-ndk-r9d/platforms/android-19/arch-arm//usr/lib
-LC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7\lib -lQt5Quick
-Lc:\Utils\android\ndk/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a
-Lc:\Utils\android\ndk/platforms/android-9/arch-arm//usr/lib
-LC:\Utils\icu32_51_1_mingw48\lib -LC:\utils\postgresql\pgsql\lib
-LC:\utils\mysql\mysql\lib -LC:\Utils\pgsql\lib
-LC:\temp\opensll-android-master\openssl-android-master\lib
-LC:\Qt\Qt5.2.1_Android\5.2.1\android_armv7/lib
-lQt5Qml
-lQt5Network
-lQt5Gui
-lQt5Core
-lGLESv2
-lgnustl_shared
-llog
-lz
-lm
-ldl
-lc
-lgcc 
도움이 되었습니까?

해결책

In short, you have three different processes running for various inputs and outputs. These namely are:

  • compiler to compile source code into object files.

  • meta object compiler to generate source code.

  • linker to link all the object files together into a binary, in this case shared librarry.

Step 1

The first created an object file out of your plugin source code using g++.

arm-linux-androideabi-g++ ... -o plugin_plugin.obj ..\plugin\plugin_plugin.cpp

Step 2

The second created an object file out of your myitem.cpp source code using g++.

arm-linux-androideabi-g++ ... -o myitem.obj ..\plugin\myitem.cpp

Step 3

The third generated the necessary moc file for your plugin using moc.

moc.exe ... ..\plugin\plugin_plugin.h -o moc_plugin_plugin.cpp

Step 4

The fourth created the object for the previously generated moc source code using g++.

arm-linux-androideabi-g++ ... -o moc_plugin_plugin.obj moc_plugin_plugin.cpp

Step 5

The fifth generated the moc source code for your myitem.cpp source code using moc.exe.

arm-linux-androideabi-g++ ... ..\plugin\myitem.h -o moc_myitem.cpp

Step 6

The sixth created the object file for the previouly created moc file using g++.

arm-linux-androideabi-g++ ... -o moc_myitem.obj moc_myitem.cpp

Step 7

The seventh and last step linked the created object file in the previous steps together using g++ for linking:

arm-linux-androideabi-g++ ... -shared -o libplugin.so plugin_plugin.obj myitem.obj
moc_plugin_plugin.obj moc_myitem.obj

These are all different steps working on different input and output files and then the file linkage happens for all of them. That is the reason why you got those commands run.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top