Opengl mit cmake und glew glfw3 und glm-Bibliotheken

Ich habe ein problem kompilieren dieses Beispiel auf 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;
}

Habe ich versucht zu kompilieren, es mit einer einzigen Zeile im terminal mit den richtigen Flaggen, aber immer auf der Suche nach Fehlern. In mehreren Foren habe ich gefunden, dass besser ist die Verwendung von cmake zu finden, link und kompilieren Sie mit den Bibliotheken, die ich brauche, also mit dieses Beispiel ich versucht, das Programm meine eigene cmake listet, ist das erlangen dieser code:

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})

Aber bekomme ich diese Fehler:

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

Wie behebe ich diesen Fehler? Oder gibt es einen einfacheren Weg das problem zu lösen?

  • Haben Sie versucht,... auf der Suche nach glew-config.cmake/glfw-config.cmake etc und Einstellung CMAKE_MODULE_PATH entsprechend vor der Ausführung von cmake?
InformationsquelleAutor user3403875 | 2014-03-10
Schreibe einen Kommentar