0

I have a sample QT application with the following raw OpenGL calls (not with QGLFunctions):

#define GL_GLEXT_PROTOTYPES
#include <QtOpenGL/QtOpenGL>

GLuint positionBuffer = 1;
glDeleteBuffers(1, &positionBuffer);

glClearColor(0, 1, 0, 1);
glClear(GL_COLOR_BUFFER_BIT);

In Windows desktop configuration I get the following linker errors:

error LNK2019: unresolved external symbol _glDeleteBuffers@8 referenced in function "public: void __thi scall OsgViewer::beforeRendering(void)" (?beforeRendering@OsgViewer@@QAEXXZ) [D:\Repos\build\geoviewer\GeoViewer.vcxpro j]

It is noteworthy that glClearColor and glClear are linked successfully. I tried both QMake and CMake with the same result.

My QMake file is:

QT += qml quick opengl

CONFIG += c++11

DEFINES += GL_GLEXT_PROTOTYPES

#see https://stackoverflow.com/questions/31688370/qt-5-5-with-qmake-linker-cannot-resolve-opengl-function-calls
#LIBS += -llibEGLd.lib -llibGLESv2d.lib
LIBS += opengl32.lib glu32.lib

VERSION = 1.0.11
DEFINES += VERSION_STRING=\\\"$$VERSION\\\"

SOURCES += main.cpp \
    squircle.cpp

#Icon files are added in the same way as in quickcontrols2\gallery\ sample
RESOURCES += qml.qrc

HEADERS += \
    squircle.h

It links fine (to ANGLE) with 'LIBS += -llibEGLd.lib -llibGLESv2d.lib' but with 'LIBS += opengl32.lib glu32.lib' it does not.

My CMake file contains:

find_package(OpenGL)
target_link_libraries(${PROJECT_NAME} ${OPENGL_LIBRARIES})

it finds glu32 and opengl32 and corresponding DLLs exist in C:/Windows/System32, but I have an impression that opengl32.dll supports some old version of OpenGL, because it has glDeleteLists, but does not have glDeleteBuffers:

enter image description here

so if I have old OpenGL libraries, the question is where to get new libraries?

Qt5OpenGL.dll has QGLFunctions::glDeleteBuffers, but does not have raw glDeleteBuffers:

enter image description here

It is interesting that OpenGLES DLL has all the functions:

enter image description here

Dmitriano
  • 957
  • 5
  • 16
  • The new(er) functions are available via the extension loading mechanism. Use `wglGetProcAddress ` see : https://msdn.microsoft.com/en-us/library/dd374386(v=vs.85).aspx QT may have this wrapped for you, not a QT expert. – Richard Critten Sep 02 '17 at 10:31
  • So looks like there is no lazy way, I should load all the functions manually after creating OpenGL context https://stackoverflow.com/questions/21769427/wglgetprocaddress-returns-null – Dmitriano Sep 02 '17 at 10:56
  • Yes, QGLFunctions wraps them. – Dmitriano Sep 02 '17 at 11:04
  • It is even possible to do this in C# http://www.dwmkerr.com/importing-opengl-extensions-functions-with-wglgetprocaddress/ – Dmitriano Sep 02 '17 at 11:07

0 Answers0