我在cpp中创build了一个简单的opengl文件。 它在大学计算机上工作。 我能够编译文件,但我不能运行编译的文件。 我得到的错误是:
Inconsistency detected by ld.so: dl-version.c: 224: _dl_check_map_versions: Assertion `needed != ((void *)0)' Failed!
// // Model.cpp // cg-projects // // Created by HUJI Computer Graphics course staff,2013. // #include "ShaderIO.h" #include "Model.h" #include <GL/glew.h> #ifdef __APPLE__ #include <OpenGL/OpenGL.h> #else #include <GL/gl.h> #endif #include <glm/glm.hpp> #include <glm/gtc/type_ptr.hpp> #include "glm/gtc/matrix_transform.hpp" #define SHADERS_DIR "shaders/" Model::Model() : _vao(0),_vbo(0) { } Model::~Model() { if (_vao != 0) glDeleteVertexArrays(1,&_vao); if (_vbo != 0) glDeleteBuffers(1,&_vbo); } void Model::init() { programManager::sharedInstance() .createProgram("default",SHADERS_DIR "SimpleShader.vert",SHADERS_DIR "SimpleShader.frag"); gluint program = programManager::sharedInstance().programWithID("default"); // Obtain uniform variable handles: _fillColorUV = glGetUniformlocation(program,"fillColor"); // Initialize vertices buffer and transfer it to OpenGL { // For this example we create a single triangle: const float vertices[] = { 0.75f,0.75f,0.0f,1.0f,-0.75f,}; // Create and bind the object's Vertex Array Object: glGenVertexArrays(1,&_vao); glBindVertexArray(_vao); // Create and load vertex data into a Vertex Buffer Object: glGenBuffers(1,&_vbo); glBindBuffer(GL_ARRAY_BUFFER,_vbo); glBufferData(GL_ARRAY_BUFFER,sizeof(vertices),vertices,GL_STATIC_DRAW); // Tells OpenGL that there is vertex data in this buffer object and what form that vertex data takes: // Obtain attribute handles: _posAttrib = glGetAttribLocation(program,"position"); glEnabLevertexAttribArray(_posAttrib); glVertexAttribPointer(_posAttrib,// attribute handle 4,// number of scalars per vertex GL_FLOAT,// scalar type GL_FALSE,0); // Unbind vertex array: glBindVertexArray(0); } } void Model::draw() { // Set the program to be used in subsequent lines: gluint program = programManager::sharedInstance().programWithID("default"); gluseProgram(program); GLenum polygonMode = GL_LINE; // Also try using GL_FILL and GL_POINT glpolygonMode(GL_FRONT_AND_BACK,polygonMode); // Set uniform variable with RGB values: float red = 0.3f; float green = 0.5f; float blue = 0.7f; gluniform4f(_fillColorUV,red,green,blue,1.0); // Draw using the state stored in the Vertex Array object: glBindVertexArray(_vao); size_t numberOfVertices = 3; glDrawArrays(GL_TRIANGLES,numberOfVertices); // Unbind the Vertex Array object glBindVertexArray(0); // Cleanup,not strictly necessary gluseProgram(0); } void Model::resize(int width,int height) { _width = width; _height = height; _offsetX = 0; _offsetY = 0; }
我使用的是Ubuntu 13.10。
如何使Cmake包含gl / GL.h?
在wglMakeCurrent中访问冲突
Vista / 7的OpenGL最多32个屏幕窗口
Qt5 QWidget :: create()与Win32 HWNDembedded不再工作在Qt4之后的端口
在Linux上安装Freeglut
在哪里下载所有需要的OpenGL库,包括和编译的DLL来制作最新的游戏?
在服务器上运行OpenGL程序,而不通过ssh窗口
模糊QT快速文本
多个SFML OpenGL窗口
它看起来有些事情已经改变了一些Ubuntu 13.10 SW更新。 我也有编译和运行没有问题的代码,只是有一天,我开始得到相同的声明`需要!=((void *)0)'失败! 错误,但只有当我用当前的gcc / lib版本再次编译我的代码。
调试后,我发现assert错误来自/lib/i386-linux-gnu/ld-2.17.so
struct link_map *needed = find_needed (strtab + ent->vn_file,map); /* If NEEDED is NULL this means a dependency was not found and no stub entry was created. This should never happen. */ assert (needed != NULL);
据说这不应该发生,它不会说什么需要,但没有找到。 一些GDB的工作,我发现它需要libpthread.so.0。 好的问题是,为什么/ usr / bin / ld链接器链接应用程序和ld.so不同意这个库的需要。
我没有故意使用libpthread,但从某处我得到我的链接地图引用__pthread_key_create @@ GLIBC_2.0我不知道这是什么地方,但它可能会导致需要libpthread.so而不添加必要的libpthread.so.0如下在objdump上-p:
Dynamic Section: NEEDED libglut.so.3 NEEDED libglu.so.1 NEEDED libGL.so.1 NEEDED libstdc++.so.6 NEEDED libgcc_s.so.1 NEEDED libpthread.so.0 NEEDED libc.so.6
我没有找到这个问题的根本原因,但最小的解决方法。 你需要链接你的代码和-pthread选项,并有一些虚拟调用这个库。
在你的Makefile库中定义
-lglut -lglu -lGL -lm -pthread
然后包含一些虚函数,只要引用一些libpthread函数来使链接器链接它,你就得到了需要的libpthread.so.0,然后ld.so是hap。
#include <pthread.h> void junk() { int i; i=pthread_getconcurrency(); };
这对我有帮助,我希望它有帮助。
有更多的分析在Ubuntu launcpad https://bugs.launchpad.net/ubuntu/+source/nvidia-graphics-drivers-319/+bug/1248642?comments=all
如果你有像我这样的NVIDIA显卡,这可能适合你
g ++ -L / usr / lib / nvidia-304 / your-file.cc -lglut -lGLEW -lGL
用nvidia驱动程序版本替换304。 关于这个bug的更多细节可以在这个链接中找到。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。