Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt GLFW and GLEW setup
Qt 6.11 is out! See what's new in the release blog

Qt GLFW and GLEW setup

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
30 Posts 3 Posters 21.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B bence

    @JonB now I know that waht was the problem I have to use

    LIBS += -L"C:\glfw\lib-vc2019" -lglfw3
    

    But this time I get 120 issues

    1.PNG

    2.PNG

    I assume that I cannot use GLFW Visual Studio precompile libary. But I cannot know what should I do.

    JonBJ Offline
    JonBJ Offline
    JonB
    wrote on last edited by
    #13

    @bence
    If you only have libraries for VS/MSVC I believe you have to use that tool chain.

    B 1 Reply Last reply
    0
    • JonBJ JonB

      @bence
      If you only have libraries for VS/MSVC I believe you have to use that tool chain.

      B Offline
      B Offline
      bence
      wrote on last edited by bence
      #14

      @JonB

      I do not install VS to my PC.

      I am sure that there is other way to do that.

      I believe Qt is a excellent platform so there have to be a way to use original OpenGL

      If you have any idea who could I use the original OpenGL in Qt I would really appriciate it.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #15

        Your issue is not related to Qt. You are trying to mix and match C++ libraries built with two different compilers. You can't use C++ libraries built with Visual Studio when using MinGW and it's the same the other way around.

        As I already explained Qt does not implement a custom version of OpenGL. You already have access the functions. You are currently making your life more complicated than need be.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        B 1 Reply Last reply
        1
        • SGaistS SGaist

          Your issue is not related to Qt. You are trying to mix and match C++ libraries built with two different compilers. You can't use C++ libraries built with Visual Studio when using MinGW and it's the same the other way around.

          As I already explained Qt does not implement a custom version of OpenGL. You already have access the functions. You are currently making your life more complicated than need be.

          B Offline
          B Offline
          bence
          wrote on last edited by bence
          #16

          @SGaist

          Simpley I do not want to install Visual Studio to use the original OpenGL that why I asked who could I do that.

          This youtube is out of date he istall the OpenGL but the current version is not the same
          Because he can install it there have to be a way that I can use it.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #17

            The page you linked provides libraries for a lot of compilers including MinGW 32 and 64 bit.

            If you can't use any of them, the compile the library yourself.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            B 1 Reply Last reply
            1
            • SGaistS SGaist

              The page you linked provides libraries for a lot of compilers including MinGW 32 and 64 bit.

              If you can't use any of them, the compile the library yourself.

              B Offline
              B Offline
              bence
              wrote on last edited by
              #18

              @SGaist
              I right click on the project and add the whole GLFW folder.

              .pro file

              TEMPLATE = app
              CONFIG += console c++11
              CONFIG -= app_bundle
              CONFIG -= qt
              
              INCLUDEPATH += "C:\glfw\include"
              INCLUDEPATH += "C:\glfw\deps"
              
              
              SOURCES += \
                      glfw/deps/getopt.c \
                      glfw/deps/glad_gl.c \
                      glfw/deps/glad_vulkan.c \
                      glfw/deps/tinycthread.c \
                      glfw/examples/boing.c \
                      glfw/examples/gears.c \
                      glfw/examples/heightmap.c \
                      glfw/examples/offscreen.c \
                      glfw/examples/particles.c \
                      glfw/examples/sharing.c \
                      glfw/examples/simple.c \
                      glfw/examples/splitview.c \
                      glfw/examples/wave.c \
                      glfw/src/cocoa_time.c \
                      glfw/src/context.c \
                      glfw/src/egl_context.c \
                      glfw/src/glx_context.c \
                      glfw/src/init.c \
                      glfw/src/input.c \
                      glfw/src/linux_joystick.c \
                      glfw/src/monitor.c \
                      glfw/src/null_init.c \
                      glfw/src/null_joystick.c \
                      glfw/src/null_monitor.c \
                      glfw/src/null_window.c \
                      glfw/src/osmesa_context.c \
                      glfw/src/posix_thread.c \
                      glfw/src/posix_time.c \
                      glfw/src/vulkan.c \
                      glfw/src/wgl_context.c \
                      glfw/src/win32_init.c \
                      glfw/src/win32_joystick.c \
                      glfw/src/win32_monitor.c \
                      glfw/src/win32_thread.c \
                      glfw/src/win32_time.c \
                      glfw/src/win32_window.c \
                      glfw/src/window.c \
                      glfw/src/wl_init.c \
                      glfw/src/wl_monitor.c \
                      glfw/src/wl_window.c \
                      glfw/src/x11_init.c \
                      glfw/src/x11_monitor.c \
                      glfw/src/x11_window.c \
                      glfw/src/xkb_unicode.c \
                      main.cpp
              
              DISTFILES += \
                  glfw/CMake/GenerateMappings.cmake \
                  glfw/CMake/MacOSXBundleInfo.plist.in \
                  glfw/CMake/i686-w64-mingw32-clang.cmake \
                  glfw/CMake/i686-w64-mingw32.cmake \
                  glfw/CMake/modules/FindEpollShim.cmake \
                  glfw/CMake/modules/FindOSMesa.cmake \
                  glfw/CMake/modules/FindWaylandProtocols.cmake \
                  glfw/CMake/modules/FindXKBCommon.cmake \
                  glfw/CMake/x86_64-w64-mingw32-clang.cmake \
                  glfw/CMake/x86_64-w64-mingw32.cmake \
                  glfw/CMakeLists.txt \
                  glfw/cmake_uninstall.cmake.in \
                  glfw/examples/CMakeLists.txt \
                  glfw/examples/glfw.icns \
                  glfw/examples/glfw.ico \
                  glfw/examples/glfw.rc \
                  glfw/src/CMakeLists.txt \
                  glfw/src/cocoa_init.m \
                  glfw/src/cocoa_joystick.m \
                  glfw/src/cocoa_monitor.m \
                  glfw/src/cocoa_window.m \
                  glfw/src/glfw3.pc.in \
                  glfw/src/glfw3Config.cmake.in \
                  glfw/src/glfw_config.h.in \
                  glfw/src/mappings.h.in \
                  glfw/src/nsgl_context.m
              
              HEADERS += \
                  glfw/deps/getopt.h \
                  glfw/deps/glad/gl.h \
                  glfw/deps/glad/khrplatform.h \
                  glfw/deps/glad/vk_platform.h \
                  glfw/deps/glad/vulkan.h \
                  glfw/deps/linmath.h \
                  glfw/deps/mingw/_mingw_dxhelper.h \
                  glfw/deps/mingw/dinput.h \
                  glfw/deps/mingw/xinput.h \
                  glfw/deps/nuklear.h \
                  glfw/deps/nuklear_glfw_gl2.h \
                  glfw/deps/stb_image_write.h \
                  glfw/deps/tinycthread.h \
                  glfw/deps/vs2008/stdint.h \
                  glfw/include/GLFW/glfw3.h \
                  glfw/include/GLFW/glfw3native.h \
                  glfw/src/cocoa_joystick.h \
                  glfw/src/cocoa_platform.h \
                  glfw/src/egl_context.h \
                  glfw/src/glx_context.h \
                  glfw/src/internal.h \
                  glfw/src/linux_joystick.h \
                  glfw/src/mappings.h \
                  glfw/src/nsgl_context.h \
                  glfw/src/null_joystick.h \
                  glfw/src/null_platform.h \
                  glfw/src/osmesa_context.h \
                  glfw/src/posix_thread.h \
                  glfw/src/posix_time.h \
                  glfw/src/wgl_context.h \
                  glfw/src/win32_joystick.h \
                  glfw/src/win32_platform.h \
                  glfw/src/wl_platform.h \
                  glfw/src/x11_platform.h \
                  glfw/src/xkb_unicode.h
              

              The Qt recognize the function so everything is good. I click on rebuilt all projects

              But when I try to built the program I get the following error:

              1.PNG

              And when I push the run button I get the a loads of errors

              2.PNG

              I use the code from link here.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #19

                GLFW already provides a mean to build their library. Use it.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                B 1 Reply Last reply
                0
                • SGaistS SGaist

                  GLFW already provides a mean to build their library. Use it.

                  B Offline
                  B Offline
                  bence
                  wrote on last edited by
                  #20

                  @SGaist

                  And who to built it. I just find the way to use it in VS.

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #21

                    Please, read the documentation of the libraries you want to use. It's explained right in their website.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    B 2 Replies Last reply
                    1
                    • SGaistS SGaist

                      Please, read the documentation of the libraries you want to use. It's explained right in their website.

                      B Offline
                      B Offline
                      bence
                      wrote on last edited by
                      #22

                      @SGaist

                      just another think link somebody says

                      LIBS += -LC:\Qt\5.13.0\mingw73_64\lib\libQt5OpenGL.a -lopengl64
                      

                      It should work but it does not work for me

                      1 Reply Last reply
                      0
                      • SGaistS SGaist

                        Please, read the documentation of the libraries you want to use. It's explained right in their website.

                        B Offline
                        B Offline
                        bence
                        wrote on last edited by
                        #23

                        @SGaist

                        Other thing is that at glfw\lib-mingw-w64 there is 3 files

                        glfw3.dll
                        libglfw3.a
                        libglfw3dll.a

                        these are libarys so I assume that I could include that so right click add external libary I add: libglfw3.a

                        .pro file

                        TEMPLATE = app
                        CONFIG += console c++11
                        CONFIG -= app_bundle
                        CONFIG -= qt
                        
                        SOURCES += main.cpp
                        
                        
                        INCLUDEPATH += C:\glfw\include
                        
                        win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../glfw/lib-mingw-w64/ -lglfw3
                        else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../glfw/lib-mingw-w64/ -lglfw3d
                        else:unix: LIBS += -L$$PWD/../../../../glfw/lib-mingw-w64/ -lglfw3
                        
                        INCLUDEPATH += $$PWD/../../../../glfw/lib-mingw-w64
                        DEPENDPATH += $$PWD/../../../../glfw/lib-mingw-w64
                        

                        So it looks good but when I try to build the program I get errors

                        :-1: error: cannot find -lglfw3d
                        :-1: error: collect2.exe: error: ld returned 1 exit status
                        
                        JonBJ 1 Reply Last reply
                        0
                        • B bence

                          @SGaist

                          Other thing is that at glfw\lib-mingw-w64 there is 3 files

                          glfw3.dll
                          libglfw3.a
                          libglfw3dll.a

                          these are libarys so I assume that I could include that so right click add external libary I add: libglfw3.a

                          .pro file

                          TEMPLATE = app
                          CONFIG += console c++11
                          CONFIG -= app_bundle
                          CONFIG -= qt
                          
                          SOURCES += main.cpp
                          
                          
                          INCLUDEPATH += C:\glfw\include
                          
                          win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../glfw/lib-mingw-w64/ -lglfw3
                          else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../glfw/lib-mingw-w64/ -lglfw3d
                          else:unix: LIBS += -L$$PWD/../../../../glfw/lib-mingw-w64/ -lglfw3
                          
                          INCLUDEPATH += $$PWD/../../../../glfw/lib-mingw-w64
                          DEPENDPATH += $$PWD/../../../../glfw/lib-mingw-w64
                          

                          So it looks good but when I try to build the program I get errors

                          :-1: error: cannot find -lglfw3d
                          :-1: error: collect2.exe: error: ld returned 1 exit status
                          
                          JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote on last edited by JonB
                          #24

                          @bence said in Qt GLFW and GLEW setup:

                          error: cannot find -lglfw3d

                          I don't know whether it would give rise to that error message, but I do not see either a .dll or a .a having that trailing d in its name. When using MSVC, debug libraries have a d on the end of their name, but I don't think that is the convention when using gcc/mingw. So are you using a linker line designed for MSVC with a build using MinGW?

                          B 1 Reply Last reply
                          1
                          • JonBJ JonB

                            @bence said in Qt GLFW and GLEW setup:

                            error: cannot find -lglfw3d

                            I don't know whether it would give rise to that error message, but I do not see either a .dll or a .a having that trailing d in its name. When using MSVC, debug libraries have a d on the end of their name, but I don't think that is the convention when using gcc/mingw. So are you using a linker line designed for MSVC with a build using MinGW?

                            B Offline
                            B Offline
                            bence
                            wrote on last edited by bence
                            #25

                            @JonB said in Qt GLFW and GLEW setup:

                            MSVC

                            At C:\glfw\lib-vc2019 there is 3 files glfw3.dll glfw3.lib glfw3dll.lib

                            At C:\glfw\lib-mingw-w64 there is 3 files glfw3.dll libglfw3.a libglfw3dll.a I am using this libary but I getting error I know that there is no d in name I add external libary I add libglfw3.a and I disable Mac and Linux platform and I also disable Add d suffix for debug version

                            lib-mingw-w64 there is nothing related to MSVS I guess

                            .pro

                            TEMPLATE = app
                            CONFIG += console c++11
                            CONFIG -= app_bundle
                            CONFIG -= qt
                            
                            INCLUDEPATH += C:\glfw\include
                            
                            win32: LIBS += -L$$PWD/../../../../glfw/lib-mingw-w64/ -lglfw3
                            
                            INCLUDEPATH += $$PWD/../../../../glfw/lib-mingw-w64
                            DEPENDPATH += $$PWD/../../../../glfw/lib-mingw-w64
                            
                            SOURCES += main.cpp
                            

                            I get 32 errors

                            undefined reference to `__imp_CreateDCW'
                            undefined reference to `__imp_GetDeviceCaps'
                            undefined reference to `__imp_DeleteDC'
                            

                            ....

                            JonBJ 1 Reply Last reply
                            0
                            • B bence

                              @JonB said in Qt GLFW and GLEW setup:

                              MSVC

                              At C:\glfw\lib-vc2019 there is 3 files glfw3.dll glfw3.lib glfw3dll.lib

                              At C:\glfw\lib-mingw-w64 there is 3 files glfw3.dll libglfw3.a libglfw3dll.a I am using this libary but I getting error I know that there is no d in name I add external libary I add libglfw3.a and I disable Mac and Linux platform and I also disable Add d suffix for debug version

                              lib-mingw-w64 there is nothing related to MSVS I guess

                              .pro

                              TEMPLATE = app
                              CONFIG += console c++11
                              CONFIG -= app_bundle
                              CONFIG -= qt
                              
                              INCLUDEPATH += C:\glfw\include
                              
                              win32: LIBS += -L$$PWD/../../../../glfw/lib-mingw-w64/ -lglfw3
                              
                              INCLUDEPATH += $$PWD/../../../../glfw/lib-mingw-w64
                              DEPENDPATH += $$PWD/../../../../glfw/lib-mingw-w64
                              
                              SOURCES += main.cpp
                              

                              I get 32 errors

                              undefined reference to `__imp_CreateDCW'
                              undefined reference to `__imp_GetDeviceCaps'
                              undefined reference to `__imp_DeleteDC'
                              

                              ....

                              JonBJ Offline
                              JonBJ Offline
                              JonB
                              wrote on last edited by JonB
                              #26

                              @bence
                              The 3 unreferenceds you list come from WinGDI. You would need to link against something link Gdi32.lib for these, which I suspect you are not doing. Or, I don't know, those leading __imp_s might indicate you are still somehow trying to link against MSVC libraries.

                              In fact I even see a stackoverflow post covering this for GLFW MinGW link error, which you should read through and follow. It says MinGW has a library libgdi32.a for these.

                              B 1 Reply Last reply
                              0
                              • JonBJ JonB

                                @bence
                                The 3 unreferenceds you list come from WinGDI. You would need to link against something link Gdi32.lib for these, which I suspect you are not doing. Or, I don't know, those leading __imp_s might indicate you are still somehow trying to link against MSVC libraries.

                                In fact I even see a stackoverflow post covering this for GLFW MinGW link error, which you should read through and follow. It says MinGW has a library libgdi32.a for these.

                                B Offline
                                B Offline
                                bence
                                wrote on last edited by bence
                                #27

                                @JonB But there is no Gdi32.lib file in the folder

                                And if I just use the following code

                                int main(void)
                                {
                                    if (!glfwInit())
                                        return -1;
                                    return 0;
                                }
                                

                                It still not woriking

                                JonBJ 1 Reply Last reply
                                0
                                • B bence

                                  @JonB But there is no Gdi32.lib file in the folder

                                  And if I just use the following code

                                  int main(void)
                                  {
                                      if (!glfwInit())
                                          return -1;
                                      return 0;
                                  }
                                  

                                  It still not woriking

                                  JonBJ Offline
                                  JonBJ Offline
                                  JonB
                                  wrote on last edited by JonB
                                  #28

                                  @bence

                                  But there is no Gdi32.lib file in the folder

                                  Please read my post and act on it.

                                  B 1 Reply Last reply
                                  0
                                  • JonBJ JonB

                                    @bence

                                    But there is no Gdi32.lib file in the folder

                                    Please read my post and act on it.

                                    B Offline
                                    B Offline
                                    bence
                                    wrote on last edited by
                                    #29

                                    @JonB

                                    The only thing that I did is I add two file. I assume that I just have to do that.

                                    .pro file

                                    TEMPLATE = app
                                    CONFIG += console c++11
                                    CONFIG -= app_bundle
                                    CONFIG -= qt
                                    
                                    INCLUDEPATH += C:\glfw\include
                                    
                                    SOURCES += main.cpp
                                    
                                    win32: LIBS += -L$$PWD/../../../../glfw/lib-mingw-w64/ -lglfw3
                                    
                                    INCLUDEPATH += $$PWD/../../../../glfw/lib-mingw-w64
                                    DEPENDPATH += $$PWD/../../../../glfw/lib-mingw-w64
                                    
                                    
                                    win32: LIBS += -L$$PWD/../../../../MinGW/lib/ -lgdi32
                                    
                                    INCLUDEPATH += $$PWD/../../../../MinGW/include
                                    DEPENDPATH += $$PWD/../../../../MinGW/include
                                    
                                    win32: LIBS += -L$$PWD/../../../../MinGW/lib/ -lopengl32
                                    
                                    INCLUDEPATH += $$PWD/../../../../MinGW/include
                                    DEPENDPATH += $$PWD/../../../../MinGW/include
                                    

                                    1.PNG

                                    1 Reply Last reply
                                    0
                                    • SGaistS Offline
                                      SGaistS Offline
                                      SGaist
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #30

                                      It looks like you are mixing two different MinGW installations.

                                      Interested in AI ? www.idiap.ch
                                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                      1 Reply Last reply
                                      0

                                      • Login

                                      • Login or register to search.
                                      • First post
                                        Last post
                                      0
                                      • Categories
                                      • Recent
                                      • Tags
                                      • Popular
                                      • Users
                                      • Groups
                                      • Search
                                      • Get Qt Extensions
                                      • Unsolved