opengl - Runtime error with GLSL shaders: Inconsistency detected by ld.so -
i writing opengl code draw small dot in window, when try use own shaders, error message don't understand.
so, here's main function:
int main(int argc, char** argv) { // initialize things glutinit(&argc, argv); glutinitdisplaymode(glut_double | glut_rgba); glutinitwindowsize(100, 100); glutcreatewindow("opengl test"); glutdisplayfunc(renderscene); glewinit(); glclearcolor(0.0f, 0.0f, 0.0f, 0.0f); // make vertex buffer vector3f vertices[1]; vertices[0] = vector3f(0.0f, 0.0f, 0.0f); glgenbuffers(1, &vertex_buffer); glbindbuffer(gl_array_buffer, vertex_buffer); glbufferdata(gl_array_buffer, sizeof(vertices), vertices, gl_static_draw); // main glut loop glutmainloop(); }
and here's rendering callback function:
static void renderscene() { glclear(gl_color_buffer_bit); glenablevertexattribarray(0); glbindbuffer(gl_array_buffer, vertex_buffer); glvertexattribpointer(0, 3, gl_float, gl_false, 0, 0); gldrawarrays(gl_points, 0, 1); gldisablevertexattribarray(0); glutswapbuffers(); }
this compiles , runs fine, displaying small white dot against black background, expected.
now, want use own shaders instead of default ones. so, in main function, before glutmainloop()
, include line:
makeshaderprogram("vertex-shader.glsl");
and function defined as:
static void makeshaderprogram(std::string shader_filename) { gluint program = glcreateprogram(); gluint shader = glcreateshader(gl_vertex_shader); const glchar* ptr_filename = &shader_filename[0]; const glchar** ptr_filenames = &ptr_filename; int filename_lengths[] = {1}; glshadersource(shader, 1, ptr_filenames, &filename_lengths[0]); glcompileshader(shader); glattachshader(program, shader); gllinkprogram(program); gluseprogram(program); }
finally, file "vertex-shader.glsl", located in same directory executable, has following contents:
#version 330 layout (location = 0) in vec3 position; void main() { gl_position = vec4(0.5 * position.x, 0.5 * position.y, position.z, 1.0); }
now, compiling fine. however, on running it, receive following error:
inconsistency detected ld.so: dl-version.c: 224: _dl_check_map_versions: assertion `needed != ((void *)0)' failed!
the program breaks right after main function starts. have no idea error message means, caused attempting use own shaders rather default shaders.
can explain going wrong?
if relevant, here cmakelists.txt
file:
cmake_minimum_required(version 2.8.1) set(cmake_cxx_flags "-std=c++11") project(opengltest) find_package(opengl required) find_package(glew required) find_package(glut required) include_directories(${opengl_include_dir} ${glew_include_dir} ${glut_include_dir}) file(glob srcs *.cpp) add_executable(${project_name} ${srcs}) target_link_libraries(${project_name} ${opengl_libraries} ${glew_library} ${glut_library})
this ubuntu bug. short version is, ubuntu messed opengl packages , introduced dependency on pthread, in programs not using pthread @ all. simple workaround solution add pthread list of libraries linked.
the bug gets triggered if non-packaged opengl implementation gets used (like amd/ati or nvidia proprietary drivers).
see https://bugs.launchpad.net/ubuntu/+source/nvidia-graphics-drivers-319/+bug/1248642
Comments
Post a Comment