Search code examples
qtqt-creatorqmake

Adding GLFW to Qt via qmake


I am using Qt 5.15.2 and Win10 64-bit

I have just downloaded the GLFW source package from the original site, not the pre-compiled binaries. I do not know how to compile it with Qt. Then I would like to use it in Qt.

I know that there are pre-compiled binaries but those can use only in Visual Studio.

I know that there is an integrated QtOpenGL to Qt but I would like to use the "original" OpenGL.

Edit:

I downloaded the 64-bit GLFW package.

The files location C:/LIBS/glfw, folder contain the following files: glfw3.dll, glfw3dll.a, libglfw3.a, glfw3.h

.pro file

TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt

SOURCES += \
        main.cpp

LIBS += -LC:/LIBS/glfw/ -lglfw3

INCLUDEPATH += C:/LIBS/glfw
DEPENDPATH += C:/LIBS/glfw

Solution

  • You don't have to compile the GLFW source package. The precompiled binary package contains binaries for both Visual Studio and MinGW.

    You have to link the OpenGL binary, so your LIBS line in the .pro file should be:

    LIBS += -LC:/LIBS/glfw/ -lglfw3 -lopengl32
    

    And you may also have to append -lglu32 and/or -lgdi32 if you still get some additional link errors.