开发者

What is missing in the CMakeLists.txt / my library installation?

I reduced my prog to the minimum just to show the pb: cmake does not compl开发者_JAVA百科ain, neither make (running Linux / libglew 1.5 / cmake 2.8.2). The program segfaults, and I have no clue why / which steps I should now make to solve the pb.

Source of render.cpp:

#include <GL/glew.h>
#include <GL/glut.h>
#include <GL/glext.h>
#ifndef WIN32
#include <GL/glx.h>
#endif

#include <iostream>
#include <assert.h>

using namespace std;

int main()
{
    cout << "Before init" << endl;
    GLenum err = glewInit();
    cout << "After init" << endl;
    if (err != GLEW_OK)
        cout << "Initialization error" << endl;
    else{        
        cout << "Successful init" << endl;
        assert(glCreateShader);
        GLuint f = glCreateShader(GL_FRAGMENT_SHADER);
    }
}

The content of CMakeList is:

cmake_minimum_required (VERSION 2.6)
project (render)
IF(CMAKE_COMPILER_IS_GNUCC)
  SET(CMAKE_CXX_FLAGS
    "${CMAKE_CXX_FLAGS} -Wall -std=c++0x")
ENDIF(CMAKE_COMPILER_IS_GNUCC)

# Some directory shortcuts
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/conf)

INCLUDE(FindOpenGL REQUIRED)
INCLUDE(FindGLEW REQUIRED)
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${GLEW_INCLUDE_DIR})

message(${OPENGL_LIBRARIES})
message(${GLEW_INCLUDE_DIR})
message(${GLEW_LIBRARIES})

add_executable(render render.cpp)
target_link_libraries(render ${GLEW_LIBRARIES} ${OPENGL_LIBRARIES})

As mentioned, it compiles and segfaults at the call to glewInit(). I have no idea what to search for at this point.. Any help would be great,

Thanks


Might be useful to anyone, I solved it: using openGL, you need to create a context before being able to call glewInit(). This can be done using the SDL library (simplifies this task). Have a look at this tutorial.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜