I’m trying to extend an existing makefile C++ project with a Qt GUI (Qt 5.6.0 because I cannot rely on Cxx11 features). The problem is I can’t get Qt to link properly. I’d like to build a X86 application (32bit) under Win7 (x86-64). I’ve installed qt-opensource-windows-x86-mingw492-5.6.0.exe obtained from the Qt download page https://download.qt.io/archive/qt/5.6/5.6.0/. Everything compiles. However, linking yields the following error:
C:/sofit/inuit_workspace/inuit_development/tools/makefiles/inuit/MakefileCatenaISS.mk:145: recipe for target 'build/model/model.exe' failed
C:/sofit/inuit_workspace/inuit_development/tools/inuit/inuit.cpp:175: undefined reference to `_imp___ZN12QApplicationC1ERiPPci'
C:/sofit/inuit_workspace/inuit_development/tools/inuit/inuit.cpp:176: undefined reference to `_imp___ZN7QWidgetC1EPS_6QFlagsIN2Qt10WindowTypeEE'
C:/sofit/inuit_workspace/inuit_development/tools/inuit/inuit.cpp:180: undefined reference to `_imp___ZN7QWidget4showEv'
C:/sofit/inuit_workspace/inuit_development/tools/inuit/inuit.cpp:181: undefined reference to `_imp___ZN12QApplication4execEv'
C:/sofit/inuit_workspace/inuit_development/tools/inuit/inuit.cpp:307: undefined reference to `_imp___ZN12QApplicationD1Ev'
C:/sofit/inuit_workspace/inuit_development/tools/inuit/inuit.cpp:307: undefined reference to `_imp___ZN12QApplicationD1Ev'
collect2.exe: error: ld returned 1 exit status
make: *** [build/model/model.exe] Error 1
I use the following command to link:
C:\Qt\Qt5.6.0\Tools\mingw492_32\bin\g++.exe -g
-LC:\Qt\Qt5.6.0\5.6\mingw49_32\lib -lQt5Widgets -lQt5Core -lQt5Gui -lQt5Cored -lQt5Guid -lQt5Widgetsd -lqtmain -lqtmaind -o build/model/model.exe ./build/model/objects/a.obj ./build/model/objects/b.obj
I’ve added a bunch of libraries and various combinations. Solely using Widgets, Core, and Gui doesn’t do the trick either.
Potential causes identified in answers in related questions (see below) aimed at - Mismatch architecture lib/compiler - Missing -lQt5Widgets
However, I don’t think this applies here. Please note that I’m not using CMake or QMake (hence no .pro file or CMake files) – just plain Gnu make called within Eclipse Mars.
The source (in case of interest):
int main(int argc, char *argv[])
QApplication app(argc, argv);
QWidget *widget = new QWidget;
Ui_MainWindow ui;
widget->show();
return app.exec();
}
And the compiler command (in case of interest):
C:\Qt\Qt5.6.0\Tools\mingw492_32\bin\g++.exe -IC:\Qt\Qt5.6.0\5.6\mingw49_32\include -IC:/my_project -Wall -g -c -DWIN32 -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT C:/my_project/1.cpp -o C:/my_project/build/model/objects/1.obj
I've tried it with/without the Qt symbols.
Does anyone know what might be the problem?
Related:
- Compiling Qt5 hello world .cpp file under Windows using MinGW-w64 gives "undefined reference" error
- C++ Qt: undefined reference to `_imp___ZN12QApplicationC1ERiPPci'
- Compiling Qt5 hello world .cpp file under Windows using MinGW-w64 gives "undefined reference" error
- http://www.qtcentre.org/archive/index.php/t-34997.html
- Qt5 linking error
Any help is highly appreciated.