我有一个示例QT应用程序,其中包含以下原始OpenGL调用(不包含QGLFunctions):
#define GL_GLEXT_PROTOTYPES
#include <QtOpenGL/QtOpenGL>
GLuint positionBuffer = 1;
glDeleteBuffers(1, &positionBuffer);
glClearColor(0, 1, 0, 1);
glClear(GL_COLOR_BUFFER_BIT);
在Windows桌面配置中,我收到以下链接器错误:
错误LNK2019:函数“public:void __thi”中引用了未解析的外部符号_glDeleteBuffers @ 8 scall OsgViewer :: beforeRendering(void)“(?beforeRendering @ OsgViewer @@ QAEXXZ)[D:\ Repos \ build \ geoviewer \ GeoViewer.vcxpro j]的
值得注意的是glClearColor和glClear已成功链接。我尝试了QMake和CMake,结果相同。
我的QMake文件是:
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
它与'LIBS + = -llibEGLd.lib -llibGLESv2d.lib'链接得很好(到ANGLE),但是'LIBS + = opengl32.lib glu32.lib'却没有。
我的CMake文件包含:
find_package(OpenGL)
target_link_libraries(${PROJECT_NAME} ${OPENGL_LIBRARIES})
它发现glu32和opengl32以及相应的DLL存在于C:/ Windows / System32中,但我的印象是opengl32.dll支持一些旧版本的OpenGL,因为它有glDeleteLists,但没有glDeleteBuffers:
所以,如果我有旧的OpenGL库,问题是在哪里获得新的库?
Qt5OpenGL.dll有QGLFunctions :: glDeleteBuffers,但没有原始glDeleteBuffers:
有趣的是,OpenGLES DLL具有所有功能: