Cross compilation C++ Linux -> Windows with Qt5
-
Hello, i am trying to do a cross compilation with MingW for Windows on Ubuntu.
I got some problems on .ui compilation.Here is my qmake.pro :
I give you the code too:
QMAKE_CXX = x86_64-w64-mingw32-g++
QMAKE_LINK = x86_64-w64-mingw32-g++
QMAKE_CXXFLAGS += -std=c++11 -m64 -Wfatal-errors
QMAKE_LFLAGS += -static-libgcc -static-libstdc++
MAKEFILE_GENERATOR = MINGW
TARGET_PLATFORM = windowsQT += gui core widgets
HEADER_DIRS += $$system(find . -type d -name "Export")
$$system(find . -type d -name "Sources")
$$system(find . -type d -name "SharedPCH")for(dir, HEADER_DIRS) {
INCLUDEPATH += $$dir
}CONFIG += relative_paths
OBJECTS_DIR = .obj
UI_DIR = .ui
MOC_DIR = .mocFORMS += $$system(find 01_IHM_CARPATHEV5 -name "*.ui")
UI_HEADERS = $(FORMS:%.ui=%.h)
HEADERS += $$system(find 01_IHM_CARPATHEV5 -name ".h")
$$system(find 01_IHM_CARPATHEV5 -name ".hpp")SOURCES += $$system(find 01_IHM_CARPATHEV5 -name ".cpp")
$$system(find 01_IHM_CARPATHEV5 -name ".c")TARGET = 01_IHM_CARPATHEV5
TEMPLATE = appLIBS += -lQt5Gui
-lws2_32
-lQt5Widgets
-lQt5CoreQMAKE_CXXFLAGS_RELEASE += -O2
QMAKE_CXXFLAGS_DEBUG += -glinux {
DEFINES += NO_WINDOWS_H
}DEFINES += Linux
In my .moc directory, i got all my moc.cpp. In my .ui directory, i also have all my ui.h. But my .obj is empty and a got this error :
I have no idea how to fix it. If you have any advices/tips/idea, it would be incredible.
Thanks in advance. -
Hi and welcome to devnet,
One thing: start smaller. You seem to have a pretty heavy application to build and are doing some strange things in your .pro file. For example, linking explicitly the Qt libraries in the .pro file is wrong as it should already be done for you through the ˋQT` keyword.
Create a simple default widget application.
As for setting up cross-compilation, you should rather create a new mkspec if none already exists to setup your build. It's not the role of the project .pro file.
You should also avoid setting the various XXX_DIR, it was mainly useful when build were done in the sources but this is something that should not be done anymore and out of source builds should be the default.
-
@SGaist said in Cross compilation C++ Linux -> Windows with Qt5:
Create a simple default widget application
Tanks for your answer, but im doing this cross compilation on docker container and i don't know if i can use QTCreator for build a widget application. You say that im doing strange things in my .pro, do you have some advices for fix that and idea of useless things i can delete ?