Reputation: 21
I have some issues with glfw3 and glew.
Here is the code :
#pragma comment(lib, "glew32.lib")
#pragma comment(lib, "glfw3dll.lib")
#include <iostream>
#include "GLEW\glew.h"
#include "GLFW\glfw3.h"
void error_callback(int error, const char* description)
{
std::cerr << description << std::endl;
}
void input_callback(GLFWwindow* wnd, int key, int scancode, int action, int mods)
{
if(key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) glfwSetWindowShouldClose(wnd, GL_TRUE);
}
int main(int argc, char** argv)
{
//init glfw
if(!glfwInit()) return EXIT_FAILURE;
//error callback
glfwSetErrorCallback(error_callback);
//create window with opengl 4.3 core profil context
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_FALSE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow* window = glfwCreateWindow(1024, 768, "glfw openGL", NULL, NULL);
if(!window)
{
glfwTerminate();
return EXIT_FAILURE;
}
//input callback
glfwSetKeyCallback(window, input_callback);
//binding context
glfwMakeContextCurrent(window);
//init glew
glewExperimental = GL_TRUE;
if(GLEW_OK != glewInit())
{
glfwDestroyWindow(window);
glfwTerminate();
return EXIT_FAILURE;
}
//generate a vertex buffer object
GLuint vbo;
glGenBuffers(1, &vbo);
//set clear color
glClearColor(100.f/255, 149.f/255, 237.f/255, 1.0);
//main loop
while(!glfwWindowShouldClose(window))
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glfwSwapBuffers(window);
glfwPollEvents();
}
//destroy window
glfwDestroyWindow(window);
//terminate glfw
glfwTerminate();
return EXIT_SUCCESS;
}
And here are the errors i get :
error LNK2019: symbole externe non rÚsolu __imp__glClear@4 rÚfÚrencÚ dans la fonction _main C:\Users\Adrien\Documents\CPP\GlfwSetup\GlfwSetup\main.obj GlfwSetup
error LNK2019: symbole externe non rÚsolu __imp__glClearColor@16 rÚfÚrencÚ dans la fonction _main C:\Users\Adrien\Documents\CPP\GlfwSetup\GlfwSetup\main.obj GlfwSetup
If I comment the glClearColor and glClear lines the program runs well (even the glGenBuffers part). So I don't understand why I can use some openGl functions but can't use some others.
OS : windows 7 64 bits. IDE : visual studio 2012 express. glfw version : 3. glew version 1.10.0.
Upvotes: 1
Views: 2394
Reputation: 21
Problem solved.
I actually forgot to link the OpenGL library.
Thank you for the help.
Upvotes: 1