Bonsoir à tous, je cherche à utiliser GLFW pour un projet OpenGL, le soucis c'est que lorsque je lance mon projet(l'exemple fourni par le site pour tester), j'obtiens cette erreur:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | C:/ludumDare/main.cpp:17: undefined reference to `glfwSetErrorCallback' C:/ludumDare/main.cpp:18: undefined reference to `glfwInit' C:/ludumDare/main.cpp:20: undefined reference to `glfwCreateWindow' C:/ludumDare/main.cpp:23: undefined reference to `glfwTerminate' C:/ludumDare/main.cpp:26: undefined reference to `glfwMakeContextCurrent' C:/ludumDare/main.cpp:27: undefined reference to `glfwSwapInterval' C:/ludumDare/main.cpp:28: undefined reference to `glfwSetKeyCallback' C:/ludumDare/main.cpp:33: undefined reference to `glfwGetFramebufferSize' C:/ludumDare/main.cpp:35: undefined reference to `_imp__glViewport@16' C:/ludumDare/main.cpp:36: undefined reference to `_imp__glClear@4' C:/ludumDare/main.cpp:37: undefined reference to `_imp__glMatrixMode@4' C:/ludumDare/main.cpp:38: undefined reference to `_imp__glLoadIdentity@0' C:/ludumDare/main.cpp:39: undefined reference to `_imp__glOrtho@48' C:/ludumDare/main.cpp:40: undefined reference to `_imp__glMatrixMode@4' C:/ludumDare/main.cpp:41: undefined reference to `_imp__glLoadIdentity@0' C:/ludumDare/main.cpp:42: undefined reference to `glfwGetTime' C:/ludumDare/main.cpp:42: undefined reference to `_imp__glRotatef@16' C:/ludumDare/main.cpp:43: undefined reference to `_imp__glBegin@4' C:/ludumDare/main.cpp:44: undefined reference to `_imp__glColor3f@12' C:/ludumDare/main.cpp:45: undefined reference to `_imp__glVertex3f@12' C:/ludumDare/main.cpp:46: undefined reference to `_imp__glColor3f@12' C:/ludumDare/main.cpp:47: undefined reference to `_imp__glVertex3f@12' C:/ludumDare/main.cpp:48: undefined reference to `_imp__glColor3f@12' C:/ludumDare/main.cpp:49: undefined reference to `_imp__glVertex3f@12' C:/ludumDare/main.cpp:50: undefined reference to `_imp__glEnd@0' C:/ludumDare/main.cpp:51: undefined reference to `glfwSwapBuffers' C:/ludumDare/main.cpp:52: undefined reference to `glfwPollEvents' C:/ludumDare/main.cpp:29: undefined reference to `glfwWindowShouldClose' C:/ludumDare/main.cpp:54: undefined reference to `glfwDestroyWindow' |
Mais malgrè mes recherches, elle persiste.
Voila donc mes codes: mon main.cpp:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | #include <GLFW/glfw3.h> #include <stdlib.h> #include <stdio.h> static void error_callback(int error, const char* description) { fputs(description, stderr); } static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) glfwSetWindowShouldClose(window, GL_TRUE); } int main(void) { GLFWwindow* window; glfwSetErrorCallback(error_callback); if (!glfwInit()) exit(EXIT_FAILURE); window = glfwCreateWindow(640, 480, "Simple example", NULL, NULL); if (!window) { glfwTerminate(); exit(EXIT_FAILURE); } glfwMakeContextCurrent(window); glfwSwapInterval(1); glfwSetKeyCallback(window, key_callback); while (!glfwWindowShouldClose(window)) { float ratio; int width, height; glfwGetFramebufferSize(window, &width, &height); ratio = width / (float) height; glViewport(0, 0, width, height); glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-ratio, ratio, -1.f, 1.f, 1.f, -1.f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glRotatef((float) glfwGetTime() * 50.f, 0.f, 0.f, 1.f); glBegin(GL_TRIANGLES); glColor3f(1.f, 0.f, 0.f); glVertex3f(-0.6f, -0.4f, 0.f); glColor3f(0.f, 1.f, 0.f); glVertex3f(0.6f, -0.4f, 0.f); glColor3f(0.f, 0.f, 1.f); glVertex3f(0.f, 0.6f, 0.f); glEnd(); glfwSwapBuffers(window); glfwPollEvents(); } glfwDestroyWindow(window); glfwTerminate(); exit(EXIT_SUCCESS); } |
Mon CMakeList.txt(j'utilise CMake et Clion, l'IDE de IDEA et je ne m'y connais pas du tout en CMake donc c'est très surement faux ....):
1 2 3 4 5 6 7 8 9 10 11 12 | cmake_minimum_required(VERSION 3.5) project(ludumDare) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set(SOURCE_FILES main.cpp) include_directories(${PROJECT_SOURCE_DIR}/GLFW/include) link_directories(${PROJECT_SOURCE_DIR}/GLFW/lib-mingw-w64) add_executable(ludumDare ${SOURCE_FILES}) target_link_libraries(ludumDare glfw3 ) |
+0
-0