У меня проблема с компиляцией этого примера в Ubuntu 12.04 LTS:
#include <stdio.h>
#include <stdlib.h>
#include <GL/glew.h>
#include <GL/glfw3.h>
#include <glm/glm.hpp>
using namespace glm;
int main(){
if( !glfwInit() )
{
fprintf( stderr, "Failed to initialize GLFW\n" );
return -1;
}
glfwWindowHint(GLFW_FSAA_SAMPLES, 4); // 4x antialiasing
glfwWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); // We want OpenGL 3.3
glfwWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //We don't want the old OpenGL
// Open a window and create its OpenGL context
GLFWwindow* window; // (In the accompanying source code, this variable is global)
window = glfwCreateWindow( 1024, 768, "Tutorial 01", NULL, NULL);
if( window == NULL ){
fprintf( stderr, "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n" );
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
// Initialize GLEW
glewExperimental=true; // Needed in core profile
if (glewInit() != GLEW_OK) {
fprintf(stderr, "Failed to initialize GLEW\n");
return -1;
}
glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);
do{
// Draw nothing, see you in tutorial 2 !
// Swap buffers
glfwSwapBuffers(window);
glfwPollEvents();
} // Check if the ESC key was pressed or the window was closed
while( glfwGetKey(window, GLFW_KEY_ESCAPE ) != GLFW_PRESS &&
glfwWindowShouldClose(window) == 0 );
return 0;
}
Я пытался скомпилировать его, используя одну строку в терминале с соответствующими флагами, но всегда находил ошибки. На нескольких форумах я обнаружил, что лучше использовать cmake для поиска, компоновки и компиляции с использованием нужных мне библиотек, поэтому с помощью этот пример я попытался запрограммировать свои собственные списки cmake, получив такой код:
cmake_minimum_required(VERSION 2.8)
#Encontrando y linkeando GLEW
find_package(GLEW REQUIRED)
include_directories(${GLEW_INCLUDE_DIRS})
link_directories(${GLEW_LIBRARY_DIRS})
add_definitions(${GLEW_DEFINITIONS})
if(NOT GLEW_FOUND)
message(Error " GLEW not found")
endif(NOT GLEW_FOUND)
#Encontrando y linkeando glfw3
find_package(GLFW REQUIRED)
include_directories(${GLFW_INCLUDE_DIRS})
link_directories(${GLFW_LIBRARY_DIRS})
add_definitions(${GLFW_DEFINITIONS})
if(NOT GLFW_FOUND)
message(Error "GLFW not found")
endif(NOT GLFW_FOUND)
#Encontrando y linkeando glm
find_package(GLM REQUIRED)
include_directories(${GLM_INCLUDE_DIRS})
link_directories(${GLM_LIBRARY_DIRS})
add_definitions(${GLM_DEFINITIONS})
if(NOT GLM_FOUND)
message(Error "GLM not found")
endif(NOT GLM_FOUND)
find_package(OpenGL REQUIRED)
include_directories(${OpenGL_INCLUDE_DIRS})
link_directories(${OpenGL_LIBRARY_DIRS})
add_definitions(${OpenGL_DEFINITIONS})
if(NOT OpenGL_FOUND)
message(Error "OpenGL not found")
endif(NOT OpenGL_FOUND)
#Incluir archivos
add_executable(abrir main.cpp)
target_link_libraries(abrir ${OPENGL_LIBRARIES} ${GLEW_LIBRARIES} ${GLFW_LIBRARIES} ${GLM_LIBRARIES})
Но я получаю эти ошибки:
Could not find module FindGLEW.cmake or a configuration file for package GLEW.
Adjust CMAKE_MODULE_PATH to find FindGLEW.cmake or set GLEW_DIR to the
directory containing a CMake configuration file for GLEW. The file will
have one of the following names:
GLEWConfig.cmake
glew-config.cmake
Error GLEW not found
CMake Error at CMakeLists.txt:14 (find_package):
Could not find module FindGLFW.cmake or a configuration file for package
GLFW.
Adjust CMAKE_MODULE_PATH to find FindGLFW.cmake or set GLFW_DIR to the
directory containing a CMake configuration file for GLFW. The file will
have one of the following names:
GLFWConfig.cmake
glfw-config.cmake
ErrorGLFW not found
CMake Error at CMakeLists.txt:25 (find_package):
Could not find module FindGLM.cmake or a configuration file for package
GLM.
Adjust CMAKE_MODULE_PATH to find FindGLM.cmake or set GLM_DIR to the
directory containing a CMake configuration file for GLM. The file will
have one of the following names:
GLMConfig.cmake
glm-config.cmake
Как я могу исправить эти ошибки? Или есть более простой способ решить проблему?