mandelcreme wrote on Tuesday, July 09, 2013:
Hi there.
I just started to program with glfw. While trying to create a simple window I always get these undefined reference errors: (not be surprised, I’m german)
#!cpp
Fehler:undefined reference to `_imp__glfwInit'
Fehler:undefined reference to `_imp__glfwCreateWindow'
Fehler:undefined reference to `_imp__glfwTerminate'
Fehler:undefined reference to `_imp__glfwMakeContextCurrent'
Fehler:undefined reference to `_imp__glfwSwapBuffers'
Fehler:undefined reference to `_imp__glfwPollEvents'
Fehler:undefined reference to `_imp__glfwWindowShouldClose'
Fehler:undefined reference to `_imp__glfwTerminate'
collect2.exe:-1: Fehler:error: ld returned 1 exit status
In this case I use the glfw3dll library. When I use the glfw3 library the error messages are the same, but without “imp_”.
That is how my .pro-file looks like:
#!cpp
TEMPLATE = app
CONFIG += console
CONFIG -= qt
SOURCES += main.cpp \
LIBS += -lglfw3dll -lopengl32 -lglu32
The libraries will be found. But it seems that there are some linker problems.
That is my main-file:
#!cpp
#define GLFW_DLL
#include <GLFW/glfw3.h>
using namespace std;
int main()
{
GLFWwindow* window;
// initialize library
if(!glfwInit()){
return -1;
}
window = glfwCreateWindow(640,480,"Test", NULL, NULL);
if(!window){
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
while(!glfwWindowShouldClose(window)){
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwTerminate();
return 0;
}
I have seen the other threads about almost the same problem. But they didn’t help me.
Can anybody tell me, what I’m doing wrong?
Note: I use the Qt Creator 5.1.0.
Many thanks in advance.