[Bug 887812] New: Can't Compile OpenGL 4 with GLEW
https://bugzilla.novell.com/show_bug.cgi?id=887812 https://bugzilla.novell.com/show_bug.cgi?id=887812#c0 Summary: Can't Compile OpenGL 4 with GLEW Classification: openSUSE Product: openSUSE 13.1 Version: Final Platform: x86-64 OS/Version: openSUSE 13.1 Status: NEW Severity: Major Priority: P5 - None Component: Development AssignedTo: bnc-team-screening@forge.provo.novell.com ReportedBy: ali.sherif10@yahoo.com QAContact: qa-bugs@suse.de Found By: --- Blocker: --- User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36 The program: #include <stdlib.h>#include <stdio.h> #include <string.h> #include <GL/glew.h> #include <GL/freeglut.h> #define WINDOW_TITLE_PREFIX "Chapter 2" int CurrentWidth = 800, CurrentHeight = 600, WindowHandle = 0; unsigned FrameCount = 0; GLuint VertexShaderId, FragmentShaderId, ProgramId, VaoId, VboId, ColorBufferId; const GLchar* VertexShader = { "#version 400\n"\ "layout(location=0) in vec4 in_Position;\n"\ "layout(location=1) in vec4 in_Color;\n"\ "out vec4 ex_Color;\n"\ "void main(void)\n"\ "{\n"\ " gl_Position = in_Position;\n"\ " ex_Color = in_Color;\n"\ "}\n" }; const GLchar* FragmentShader = { "#version 400\n"\ "in vec4 ex_Color;\n"\ "out vec4 out_Color;\n"\ "void main(void)\n"\ "{\n"\ " out_Color = ex_Color;\n"\ "}\n" }; void Initialize(int, char*[]); void InitWindow(int, char*[]); void ResizeFunction(int, int); void RenderFunction(void); void TimerFunction(int); void IdleFunction(void); void Cleanup(void); void CreateVBO(void); void DestroyVBO(void); void CreateShaders(void); void DestroyShaders(void); int main(int argc, char* argv[]) { Initialize(argc, argv); glutMainLoop(); exit(EXIT_SUCCESS); } void Initialize(int argc, char* argv[]) { GLenum GlewInitResult; InitWindow(argc, argv); glewExperimental = GL_TRUE; GlewInitResult = glewInit(); if (GLEW_OK != GlewInitResult) { fprintf( stderr, "ERROR: %s\n", glewGetErrorString(GlewInitResult) ); exit(EXIT_FAILURE); } fprintf( stdout, "INFO: OpenGL Version: %s\n", glGetString(GL_VERSION) ); CreateShaders(); CreateVBO(); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); } void InitWindow(int argc, char* argv[]) { glutInit(&argc, argv); glutInitContextVersion(4, 0); glutInitContextFlags(GLUT_FORWARD_COMPATIBLE); glutInitContextProfile(GLUT_CORE_PROFILE); glutSetOption( GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS ); glutInitWindowSize(CurrentWidth, CurrentHeight); glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); WindowHandle = glutCreateWindow(WINDOW_TITLE_PREFIX); if(WindowHandle < 1) { fprintf( stderr, "ERROR: Could not create a new rendering window.\n" ); exit(EXIT_FAILURE); } glutReshapeFunc(ResizeFunction); glutDisplayFunc(RenderFunction); glutIdleFunc(IdleFunction); glutTimerFunc(0, TimerFunction, 0); glutCloseFunc(Cleanup); } void ResizeFunction(int Width, int Height) { CurrentWidth = Width; CurrentHeight = Height; glViewport(0, 0, CurrentWidth, CurrentHeight); } void RenderFunction(void) { ++FrameCount; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glDrawArrays(GL_TRIANGLES, 0, 6); glutSwapBuffers(); } void IdleFunction(void) { glutPostRedisplay(); } void TimerFunction(int Value) { if (0 != Value) { char* TempString = (char*) malloc(512 + strlen(WINDOW_TITLE_PREFIX)); sprintf( TempString, "%s: %d Frames Per Second @ %d x %d", WINDOW_TITLE_PREFIX, FrameCount * 4, CurrentWidth, CurrentHeight ); glutSetWindowTitle(TempString); free(TempString); } FrameCount = 0; glutTimerFunc(250, TimerFunction, 1); } void Cleanup(void) { DestroyShaders(); DestroyVBO(); } void CreateVBO(void) { GLfloat Vertices[] = { -0.8f, 0.8f, 0.0f, 1.0f, 0.8f, 0.8f, 0.0f, 1.0f, -0.8f, -0.8f, 0.0f, 1.0f, -0.8f, -0.8f, 0.0f, 1.0f, 0.8f, 0.8f, 0.0f, 1.0f, 0.8f, -0.8f, 0.0f, 1.0f }; GLfloat Colors[] = { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }; GLenum ErrorCheckValue = glGetError(); glGenVertexArrays(1, &VaoId); glBindVertexArray(VaoId); glGenBuffers(1, &VboId); glBindBuffer(GL_ARRAY_BUFFER, VboId); glBufferData(GL_ARRAY_BUFFER, sizeof(Vertices), Vertices, GL_STATIC_DRAW); glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(0); glGenBuffers(1, &ColorBufferId); glBindBuffer(GL_ARRAY_BUFFER, ColorBufferId); glBufferData(GL_ARRAY_BUFFER, sizeof(Colors), Colors, GL_STATIC_DRAW); glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(1); ErrorCheckValue = glGetError(); if (ErrorCheckValue != GL_NO_ERROR) { fprintf( stderr, "ERROR: Could not create a VBO: %s \n", gluErrorString(ErrorCheckValue) ); exit(-1); } } void DestroyVBO(void) { GLenum ErrorCheckValue = glGetError(); glDisableVertexAttribArray(1); glDisableVertexAttribArray(0); glBindBuffer(GL_ARRAY_BUFFER, 0); glDeleteBuffers(1, &ColorBufferId); glDeleteBuffers(1, &VboId); glBindVertexArray(0); glDeleteVertexArrays(1, &VaoId); ErrorCheckValue = glGetError(); if (ErrorCheckValue != GL_NO_ERROR) { fprintf( stderr, "ERROR: Could not destroy the VBO: %s \n", gluErrorString(ErrorCheckValue) ); exit(-1); } } void CreateShaders(void) { GLenum ErrorCheckValue = glGetError(); VertexShaderId = glCreateShader(GL_VERTEX_SHADER); glShaderSource(VertexShaderId, 1, &VertexShader, NULL); glCompileShader(VertexShaderId); FragmentShaderId = glCreateShader(GL_FRAGMENT_SHADER); glShaderSource(FragmentShaderId, 1, &FragmentShader, NULL); glCompileShader(FragmentShaderId); ProgramId = glCreateProgram(); glAttachShader(ProgramId, VertexShaderId); glAttachShader(ProgramId, FragmentShaderId); glLinkProgram(ProgramId); glUseProgram(ProgramId); ErrorCheckValue = glGetError(); if (ErrorCheckValue != GL_NO_ERROR) { fprintf( stderr, "ERROR: Could not create the shaders: %s \n", gluErrorString(ErrorCheckValue) ); exit(-1); } } void DestroyShaders(void) { GLenum ErrorCheckValue = glGetError(); glUseProgram(0); glDetachShader(ProgramId, VertexShaderId); glDetachShader(ProgramId, FragmentShaderId); glDeleteShader(FragmentShaderId); glDeleteShader(VertexShaderId); glDeleteProgram(ProgramId); ErrorCheckValue = glGetError(); if (ErrorCheckValue != GL_NO_ERROR) { fprintf( stderr, "ERROR: Could not destroy the shaders: %s \n", gluErrorString(ErrorCheckValue) ); exit(-1); } } Command: g++ -o test file.cpp -lGLEW -lglut Reproducible: Always Steps to Reproduce: 1. Make any OpenGL 4 program. 2. Compile it. Actual Results: /usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: /tmp/ccrJgTa8.o: undefined reference to symbol 'glClear'/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: note: 'glClear' is defined in DSO /usr/X11R6/lib64/libGL.so.1 so try adding it to the linker command line /usr/X11R6/lib64/libGL.so.1: could not read symbols: Invalid operation collect2: error: ld returned 1 exit status It seems that -lGL is from Mesa, although I installed fglrx 64-bit. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=887812 https://bugzilla.novell.com/show_bug.cgi?id=887812#c Sherif Ahmed <ali.sherif10@yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P5 - None |P2 - High -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=887812 https://bugzilla.novell.com/show_bug.cgi?id=887812#c Bernhard Wiedemann <bwiedemann@suse.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bwiedemann@suse.com Component|Development |X11 3rd Party Driver QAContact|qa-bugs@suse.de |sndirsch@suse.com -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=887812 https://bugzilla.novell.com/show_bug.cgi?id=887812#c1 Stefan Dirsch <sndirsch@suse.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |NEEDINFO InfoProvider| |ali.sherif10@yahoo.com --- Comment #1 from Stefan Dirsch <sndirsch@suse.com> 2014-08-11 14:50:52 UTC --- Use g++ -o test test.cpp -lGLEW -lglut -lGL -lGLU instead? Isn't this consulting? -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=887812 https://bugzilla.novell.com/show_bug.cgi?id=887812#c2 --- Comment #2 from Sherif Ahmed <ali.sherif10@yahoo.com> 2014-08-14 14:32:02 UTC --- Hi, really sorry, I don't have OpenSUSE now, but it worked on Ubuntu. I hope this helps. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=887812 https://bugzilla.novell.com/show_bug.cgi?id=887812#c3 Stefan Dirsch <sndirsch@suse.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEEDINFO |RESOLVED InfoProvider|ali.sherif10@yahoo.com | Resolution| |INVALID --- Comment #3 from Stefan Dirsch <sndirsch@suse.com> 2014-08-14 14:39:04 UTC --- This is not a bugreport, it is a consulting question. Closing as invalid. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
participants (1)
-
bugzilla_noreply@novell.com