Somebody ported my code to linux using cmake. They got it to run, but when I tried to compile it with cmake it complained that libGL.so was missing DSO or something.
I fixed it (correctly or not) like this:
CMakeLists.txt
...
ADD_DEFINITIONS("-std=c++0x"
-lGL
-lGLU
-lGLEW)
...
FIND_PACKAGE(OpenGL REQUIRED)
FIND_PACKAGE(GLEW REQUIRED)
...
TARGET_LINK_LIBRARIES(
...
${GL_LIBRARIES}
${GLU_LIBRARIES}
...
${OPENGL_LIBRARIES}
)
That was enough to compile the program. But it complained about "Couldn't create GL context" at the end here:
g_log<<"samw0"<<endl;
g_log.flush();
g_log<<"GL_VERSION: "<<(char*)glGetString(GL_VERSION)<<endl;
g_log.flush();
g_log<<"sa"<<endl;
g_log.flush();
// Request compatibility because GLEW doesn't play well with core contexts.
#if 1
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
#endif
unsigned int flags;
int startx;
int starty;
if(g_fullscreen)
{
startx = SDL_WINDOWPOS_UNDEFINED;
starty = SDL_WINDOWPOS_UNDEFINED;
flags = SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN;
}
else
{
startx = SDL_WINDOWPOS_UNDEFINED;
starty = SDL_WINDOWPOS_UNDEFINED;
flags = SDL_WINDOW_OPENGL;
}
// Create an application window with the following settings:
g_window = SDL_CreateWindow(
title, // window title
startx, // initial x position
starty, // initial y position
g_selectedRes.width, // width, in pixels
g_selectedRes.height, // height, in pixels
flags // flags - see below
);
...
g_glcontext = SDL_GL_CreateContext(g_window);
//SDL_GL_SetSwapInterval(1);
g_log<<"GL_VERSION: "<<glGetString(GL_VERSION)<<endl;
if(!g_glcontext)
{
DestroyWindow(title);
ErrorMessage("Error", "Couldn't create GL context");
return false;
}
You can see at the very beginning there I try to check GL version:
g_log<<"GL_VERSION: "<<(char*)glGetString(GL_VERSION)<<endl;
But there's some kind of problem because all I see in the log is:
samw0
GL_VERSION:
And after that there's nothing, even though the program doesn't stop there. So it seems like I'm linking to GL wrong or something.
How do I diagnose the problem? Do I walk through the dependencies or something (how)?
Should it be red when make says:
Linking CXX executable corpstatesc
?