There is a Qt project with files:
untitled2.pro
QT += opengl greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = untitled2 TEMPLATE = app SOURCES += main.cpp\ wopengl.cpp HEADERS += \ wopengl.h main.cpp
#include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); return a.exec(); } wopengl.h
#ifndef WOPENGL_H #define WOPENGL_H #include <QGLWidget> class WOpengl : public QGLWidget{ public: void scene(); }; #endif // WOPENGL_H wopengl.cpp
#include "wopengl.h" #include <QtOpenGL> #include <GL/gl.h> void WOpengl::scene(){ glVertex3f(0.0, 0.0, 0.0); } Project build options:
qmake.exe D:\fil\qt\simple_3D\untitled2.pro -spec win32-msvc2015 "CONFIG+=debug" "CONFIG+=qml_debug" && C:/Qt/Qt5.7.1/Tools/QtCreator/bin/jom.exe qmake_all When building I get an error:
wopengl.obj: -1: error: LNK2019: link to unresolved external symbol __imp_glVertex3f in the function "public: void __cdecl WOpengl :: scene (void)" (? scene @ WOpengl @@ QEAAXXZ)
.....
From the environment, the identifier glVertex3f is visible, but not when built. I do not understand the reason?
.....
Detailed conclusion of the reason:
15:44:50: Выполняются этапы для проекта untitled2... 15:44:50: Настройки не изменились, этап qmake пропускается. 15:44:50: Запускается: «C:\Qt\Qt5.7.1\Tools\QtCreator\bin\jom.exe» C:\Qt\Qt5.7.1\Tools\QtCreator\bin\jom.exe -f Makefile.Debug link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:debug\untitled2.exe @C:\Users\vvf\AppData\Local\Temp\untitled2.exe.4844.0.jom wopengl.obj : error LNK2019: ссылка на неразрешенный внешний символ __imp_glVertex3f в функции "public: void __cdecl WOpengl::scene(void)" (?scene@WOpengl@@QEAAXXZ) debug\untitled2.exe : fatal error LNK1120: неразрешенных внешних элементов: 1 jom: D:\fil\qt\build-untitled2-Desktop_Qt_5_7_1_MSVC2015_64bit-Debug\Makefile.Debug [debug\untitled2.exe] Error 1120 jom: D:\fil\qt\build-untitled2-Desktop_Qt_5_7_1_MSVC2015_64bit-Debug\Makefile [debug] Error 2 15:44:50: Процесс «C:\Qt\Qt5.7.1\Tools\QtCreator\bin\jom.exe» завершился с кодом 2. Ошибка при сборке/установке проекта untitled2 (комплект: Desktop Qt 5.7.1 MSVC2015_64bit) Комплект Desktop Qt 5.7.1 MSVC2015_64bit имеет недостатки в конфигурации, которые могут быть источниками данной проблемы. Во время выполнения этапа «Сборка» 15:44:50: Прошло времени: 00:01.
#pragma comment( lib, "OpenGL32.lib" )and everything starts working. the source is not mine, why does it work (without pragma) and I don’t? - perfectQT += openglin a pro-file, theQT += openglshould include all the files needed for opengllib. - perfect