Details
Description
test.qbs
import qbs.base 1.0 Application { Depends { name: "cpp" } Depends { name: "Qt"; submodules: ["gui", "widgets", "opengl"] } name: "test" files: ["main.cpp"] }
main.cpp
#include <QApplication> #include <QGLWidget> class Renderer : public QGLWidget { protected: void resizeGL(int w, int h) { glViewport(0, 0, w, h); } }; int main(int argc, char *argv[]) { QApplication app(argc, argv); Renderer win; win.show(); return app.exec(); }
Compilation output:
compiling main.cpp linking test.exe C:/Qt/Tools/mingw48_32/bin/g++.exe -m32 -O2 -Wall -Wextra D:/test-build/qtc_Desktop_Qt_5_2_0_MinGW_32bit-release/.obj/test/main.cpp.o -o D:/test-build/qtc_Desktop_Qt_5_2_0_MinGW_32bit-release/test.exe -LC:/Qt/5.2.0/mingw48_32/lib -lqtmain -lQt5Core -lQt5Gui -lQt5OpenGL -lQt5Widgets D:/test-build/qtc_Desktop_Qt_5_2_0_MinGW_32bit-release/.obj/test/main.cpp.o:main.cpp:(.text$_ZN8Renderer8resizeGLEii[__ZN8Renderer8resizeGLEii]+0x24): undefined reference to `_imp__glViewport@16' collect2.exe: error: ld returned 1 exit status Process failed with exit code 1. The following products could not be built for configuration qtc_Desktop_Qt_5_2_0_MinGW_32bit-release: test.
But qmake compiles it successfully using equivalent .pro file:
QT = core gui widgets opengl TARGET = test TEMPLATE = app SOURCES = main.cpp
and produses next output:
g++ -Wl,-s -Wl,-subsystem,windows -mthreads -o release\test.exe release/main.o -lglu32 -lopengl32 -lgdi32 -luser32 -lmingw32 -lqtmain -LC:\Qt\5.2.0\mingw48_32\lib -lQt5OpenGL -lQt5Widgets -lQt5Gui -lQt5Core