Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Opengl doesn't work with Qt
QtWS25 Last Chance

Opengl doesn't work with Qt

Scheduled Pinned Locked Moved Installation and Deployment
24 Posts 5 Posters 22.3k Views
  • 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.
  • F Offline
    F Offline
    fery13
    wrote on 25 Jun 2011, 14:10 last edited by
    #1

    Hi Guys, I am using windows 7 and trying to writing my c++ codes in Qt using opengl, but always I have problem which can not open opengl library like glut or glut32, I search a lot but no correct answer, please help me ...

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DenisKormalev
      wrote on 25 Jun 2011, 14:21 last edited by
      #2

      Maybe you can provide more info? Errors, sample code, etc.?

      P.S. And it is Qt, not QT :) Please change title

      1 Reply Last reply
      0
      • F Offline
        F Offline
        fery13
        wrote on 25 Jun 2011, 15:26 last edited by
        #3

        Hi Thanks for P.S ;) .... it's a very simple code to draw a line just for test, but the error happens when it wants to be complied, the error is about opengl calling function like "glutDisplayFunc(display)" or "glutInit(&argc, argv)" which can not refer to them, I check .pro file in Qt and the command Qt+= opengl is exist, so I guess there should be an other problem.....

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DenisKormalev
          wrote on 25 Jun 2011, 15:36 last edited by
          #4

          Can you post here exact error? I doubt that I will help (never tried opengl under windows), but it will be easier for others to help with all info you can give.

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            ZapB
            wrote on 25 Jun 2011, 18:18 last edited by
            #5

            You need to link to glut too since this is not part of the core OpenGL but rather an add-on utility library. Just add

            @
            LIBS += -lglut
            @

            to your project's .pro file, re-run qmake and build.

            Nokia Certified Qt Specialist
            Interested in hearing about Qt related work

            1 Reply Last reply
            0
            • F Offline
              F Offline
              fery13
              wrote on 27 Jun 2011, 14:30 last edited by
              #6

              Hi Guys sorry for my late reply, here is errors :

              C:\Users\FGHASSEMIT\ne1\ne1.cpp:-1: error: undefined reference to __glutInitWithExit@12' C:\Users\FGHASSEMIT\ne1\ne1.cpp:-1: error: undefined reference to glutInitDisplayMode@4'
              C:\Users\FGHASSEMIT\ne1\ne1.cpp:-1: error: undefined reference to glutInitWindowSize@8' C:\Users\FGHASSEMIT\ne1\ne1.cpp:-1: error: undefined reference to glutInitWindowPosition@8'
              C:\Users\FGHASSEMIT\ne1\ne1.cpp:-1: error: undefined reference to __glutCreateWindowWithExit@8' C:\Users\FGHASSEMIT\ne1\ne1.cpp:-1: error: undefined reference to glutDisplayFunc@4'
              C:\Users\FGHASSEMIT\ne1\ne1.cpp:-1: error: undefined reference to `glutMainLoop@0'
              :-1: error: collect2: ld returned 1 exit status

              and here is my .pro file :

              TARGET = ne1

              TEMPLATE = app

              DEPENDPATH += .

              INCLUDEPATH += .

              SOURCES += ne1.cpp

              HEADERS += ne1.h
              ne1_global.h

              CONFIG += opengl
              release

              QT += opengl

              LIBS += -glut32 -glut


              for "LIBS += " I changed for only -glut but still the same errors come ...
              Looking forward for your solution
              Thanks in advance .

              1 Reply Last reply
              0
              • Z Offline
                Z Offline
                ZapB
                wrote on 27 Jun 2011, 14:36 last edited by
                #7

                @
                LIBS += -lglut
                @

                notice the -l. The following .pro file works for me with a simple OpenGL example that uses glut:

                @
                QT += opengl

                TARGET = 06-solar-system
                TEMPLATE = app

                SOURCES += main.cpp
                solarsystem.cpp

                HEADERS += solarsystem.h

                LIBS += -lglut
                @

                Nokia Certified Qt Specialist
                Interested in hearing about Qt related work

                1 Reply Last reply
                0
                • F Offline
                  F Offline
                  fery13
                  wrote on 27 Jun 2011, 14:47 last edited by
                  #8

                  I guess you work with linux, I used this command as well then I have error that says can not find lglut, one of my colleague work with linux and uses LIBS += -lglut and he can work but for me it doenst work since I am using windows 7 ....
                  :(

                  1 Reply Last reply
                  0
                  • Z Offline
                    Z Offline
                    ZapB
                    wrote on 27 Jun 2011, 14:53 last edited by
                    #9

                    True. I'll try it on windows tonight.

                    Nokia Certified Qt Specialist
                    Interested in hearing about Qt related work

                    1 Reply Last reply
                    0
                    • F Offline
                      F Offline
                      fery13
                      wrote on 27 Jun 2011, 14:58 last edited by
                      #10

                      oh many many thanks ... I am eagerly looking forward to hear good news from you ...... :)

                      1 Reply Last reply
                      0
                      • L Offline
                        L Offline
                        ludde
                        wrote on 27 Jun 2011, 17:27 last edited by
                        #11

                        If you really want ot use GLUT, I think you'll have to find a Windows port of GLUT, and install it, e.g. "this one":http://www.xmission.com/~nate/glut.html. Then, you must add the library, as well as the path to where you installed it, to the LIBS variable. And possible set the include path as well.

                        But, most of the things you get from using GLUT are things you don't really need when you use OpenGL with Qt. It makes sense to use GLUT or Qt, but not really both.

                        1 Reply Last reply
                        0
                        • F Offline
                          F Offline
                          fery13
                          wrote on 27 Jun 2011, 17:35 last edited by
                          #12

                          Is it something different with the glut which I am currently using in c++ under the same windows ??? because in c++ I have no problem with openGl and all its library only in Qt ...

                          1 Reply Last reply
                          0
                          • L Offline
                            L Offline
                            ludde
                            wrote on 27 Jun 2011, 17:44 last edited by
                            #13

                            You are saying that you can use GLUT from plain C++ code, but not from Qt code? In that case you must have it installed somewhere already. You just need to tell where, in your .pro file, so that qmake can find it. I.e., you must add something like:
                            @
                            LIBS += -lglut
                            LIBS += -LC:/location/of/glut
                            @
                            I'm not sure this is what's missing, though. Since you don't get an error saying it cannot find the glut library. Looks like it actually finds it, but not the symbols it needs. Strange.

                            Which compiler are you using? The same one you use when compiling plain C++ code?

                            1 Reply Last reply
                            0
                            • F Offline
                              F Offline
                              fery13
                              wrote on 27 Jun 2011, 17:53 last edited by
                              #14

                              Yes I am using in plain C++ without problem,
                              But I can not find any file like lglut in my pc(where can I get this file) ??????
                              I have only glut, glut32 (header file and lib file )....
                              but I never tried the second line which you mentioned above, I will try the second one seems by the second line error should be gone hopefully by the way now I uninstall the Qt and trying to get the new version as soon as I install I will apply this and I will let you know about it .... many many thanks to you that spend your time for my problem .....

                              1 Reply Last reply
                              0
                              • U Offline
                                U Offline
                                ucomesdag
                                wrote on 27 Jun 2011, 18:03 last edited by
                                #15

                                -l stands for library and -L for library path, see "qmake doc":http://doc.qt.nokia.com/4.7/qmake-variable-reference.html#libs
                                [quote author="fery13" date="1309197219"]Yes I am using in plain C++ without problem,
                                But I can not find any file like lglut in my pc(where can I get this file) ??????
                                I have only glut, glut32 (header file and lib file ).... [/quote]

                                Write “Qt”, not “QT” (QuickTime).

                                1 Reply Last reply
                                0
                                • L Offline
                                  L Offline
                                  ludde
                                  wrote on 27 Jun 2011, 18:08 last edited by
                                  #16

                                  -lglut is like a command line option, which you use to tell qmake to use a library. -l is the option and glut the argument. On Windows, the file should be called glut.lib. -L is used to add a directory in which to look for libraries.

                                  I don't think this is the problem, though. It seems to find GLUT and is unable to link with it. Maybe you simply cannot do this, because using those functions mentioned above together with Qt really makes no sense.

                                  1 Reply Last reply
                                  0
                                  • U Offline
                                    U Offline
                                    ucomesdag
                                    wrote on 27 Jun 2011, 18:27 last edited by
                                    #17

                                    Try @LIBS += -L/path/to/your/lib -lLibfile_without_exstension@

                                    Write “Qt”, not “QT” (QuickTime).

                                    1 Reply Last reply
                                    0
                                    • L Offline
                                      L Offline
                                      ludde
                                      wrote on 27 Jun 2011, 19:08 last edited by
                                      #18

                                      Just had a look in my OpenGL installation, which is the one that comes with mingw / Qt Creator, and it contains glu, but not glut. So your glut must come from somewhere else.

                                      1 Reply Last reply
                                      0
                                      • F Offline
                                        F Offline
                                        fery13
                                        wrote on 28 Jun 2011, 12:02 last edited by
                                        #19

                                        That's strange I tried all, but still errors, also I re install Qt ... here is my .pro:
                                        @
                                        #-------------------------------------------------

                                        Project created by QtCreator 2011-06-23T18:42:17

                                        #-------------------------------------------------

                                        TARGET = open1

                                        TEMPLATE = app

                                        DEPENDPATH += .

                                        INCLUDEPATH += .

                                        SOURCES += open1.cpp

                                        HEADERS += open1.h
                                        open1_global.h

                                        CONFIG += opengl
                                        release

                                        QT += opengl

                                        LIBS += -lglut
                                        LIBS += C:\Users\FGHASSEMIT\Documents\qt\GL\glut.lib
                                        @
                                        and here errors :

                                        :-1: error: cannot find -lglut
                                        :-1: error: collect2: ld returned 1 exit status

                                        .................
                                        this is the same if I write glut32 instead of glut ....
                                        :(

                                        Edit: Added @ tags

                                        1 Reply Last reply
                                        0
                                        • Z Offline
                                          Z Offline
                                          ZapB
                                          wrote on 28 Jun 2011, 12:07 last edited by
                                          #20

                                          Try also adding:

                                          @
                                          LIBS += -LC:/path/to/your/glut/lib
                                          @

                                          Nokia Certified Qt Specialist
                                          Interested in hearing about Qt related work

                                          1 Reply Last reply
                                          0

                                          4/24

                                          25 Jun 2011, 15:36

                                          topic:navigator.unread, 20
                                          • Login

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