[SOLVED] GLEW linking errors with Qt Creator 2.5.2
-
I modified my .pro to have just those 2 lines you posted but I'm still getting the same linking errors. Is there something that I may be missing externally? Or could there be a possibility that other packages be conflicting with the linking?
And I constantly run qmake with every change made
-
Not that I know of.
Just to be sure - build or rebuild is not the same as running qmake.
What compiler are you using - MinGW or VC and which version?Offtopic question - why still Creator 2.5.2? It's very old. Current version is 3.1.0
-
I believe I'm using MinGW. I don't know how to check the version. I obtained my current version of MinGW from installing QtSDK at this "link":http://download.cnet.com/Qt-SDK/3000-2069_4-75305206.html
Addressing your off topic question -
I'm using Creator 2.5.2 because I believe that's what my Graphics class used last year. I tried using Creator 3.1.0 but I didn't understand how a kit worked and how to install one. I just wanted to continue my project from last year right away and over time, switch to Creator 3.1.0 -
Actually, it's better to say my tool chain has auto-detected both MinGW (as a GCC for Windows targets) and MSVC Visual C++ Compiler 12.0. But when I'm compiling, it's using mingw32-make.exe
-
Hm, I might be wrong, but aren't the binaries distributed with GLEW incompatible with MinGW? I think you need to compile GLEW from source using MinGW.
The SDK you have is also quite old. The best way to install all you need is usually via online installer directly from "Qt downloads page":http://qt-project.org/downloads
It will allow you to select a version and compiler you want and will set up kits and all the stuff for you.
A kit is actually just a collection of tools in the chain needed for development: a compiler, debugger and a Qt library packed in one, named configuration that you can select when creating project. -
Thanks for the explanation on a kit. I went and installed the "Qt Online Installer":http://qt-project.org/downloads, and was surprised that everything was set up for me.
So now I believe I'm running the latest Qt Creator, which came with the installer. I'm now running the following:
- Compiler: MinGW 4.8 32bit
- Qt 5.2.1
I'm still getting the same errors.
You also mentioned about the binaries distributed with GLEW may be incompatible with MinGW. How do I compile GLEW from source using MinGW, and what does that do?
-
Yeah, the binaries (dll and lib files) are built with some old version of VC (not sure which) and it seems they don't play well with MinGW.
Download the "source package":https://sourceforge.net/projects/glew/files/glew/1.10.0/glew-1.10.0.zip/download of GLEW
If you don't know how to compile it look around on the web. I can't give you specific instructions since it's been a while since I used GLEW and MinGW together, but it should be as easy as setting some environment variables and running mingw32-make with some options.What it does - it creates libraries compiled by and compatible with MinGW ;) You see the .dll file in the bin folder and .lib in the lib folder? The .lib one is the one you use with the LIBS entry in your .pro file, the .dll is needed at runtime and you distribute it with your app.
Compiling with MinGW will create these (except the .lib one will have .a extension, that's the "native" format of MinGW). -
I was just thinking - do you really need GLEW at all? Qt has pretty nice OpenGL supporty built in and it can resolve all the function pointers just as GLEW does.
You can just subclass QOpenGLFunctions_4_3_Core (or whichever OpenGL version you want to target) and use OpenGL inside it like you would normally. -
Thanks for the explanations. And I did not know about the class QOpenGLFunctions. I checked it out and it has the same function calls from GLEW. This is amazing! I will be away from my main computer for a few days so I'll test it out once I get back.
-
Okay, so I have completely abandoned GLEW in favor for "QGLFunctions":http://qt-project.org/doc/qt-5/qopenglfunctions-4-3-core.html and it is now working. If anyone else is interested, here is how part of my code is set up:
@#include <QGLWidget>
#include <QOpenGLFunctions_4_3_Core>
#include "readOBJ.h"class GLDisplay : public QGLWidget, protected QOpenGLFunctions_4_3_Core
{
public:
GLDisplay(char *, QWidget *parent = 0);
void createOBJ(char *);
GLuint loadShaders(const char *, const char *);
@Also, it appears that in order to use QOpenGLFunctions_4_3_Core, you have to call "setSurfaceType":http://qt-project.org/doc/qt-5/qwindow.html#setSurfaceType(OpenGLType) from the QWindow class. Otherwise, Seg Faults will occur.
If QOpenGLFunctions is used instead, then this is not necessary, but QOpenGLFunctions lack certain functions that _4_3_Core has (i.e. glGenVertexArrays() to set up VAO).
Thanks again Chris.