Linking glut to Qt

2019-03-02 16:43发布

问题:

I want to combine OpenGL with glut to Qt. I'm using Windows. My version of Qt is 4.7.4, 32 bit.

I followed the tutorial:

http://www.youtube.com/watch?v=1nzHSkY4K18

I also checked some other questions of people but they didn't gave me an answer.

The part before including glut works fine. But when I try to include glut it doesn't work. The errors are:

undefined reference to glutInit_ATEXIT_HACK

and more undefined references to glutfunctions.

I copied the glut-libraries and headers to the appropriate folders in the MinGW folder. But I wasn't sure if this was the right folder.

回答1:

MinGW:

Copy glut.h to %dir%\MinGW\include\GL

Copy glut32.lib to %dir%\MinGW\lib

Copy glut32.dll to C:\windows\system32

Add %dir%\MinGW\bin to the system's environmental variables.

Visual Studio:

Navigate to

%dir% \Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\

Place the .h files in ...\include\GL

Place the .lib files in ...\lib

Restart Visual Studio.