Answer the question
In order to leave comments, you need to log in
Why can't it find the function?
Hello! Faced such a problem: At the compilation stage, the compiler gives an error message (compiled with the following flags: gcc demo.c -lglut -Werror -Wextra -Wall -o program):
/usr/bin/ld: /tmp/ccic0NXk.o : undefined reference to symbol 'glVertex3f'
/usr/bin/ld: /lib/x86_64-linux-gnu/libGL.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit
status So:
#include <GL/glut.h>
void renderScene(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glVertex3f(-0.5,-0.5,0.0);
glVertex3f(0.0,0.5,0.0);
glVertex3f(0.5,-0.5,0.0);
glEnd();
glutSwapBuffers();
}
int main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(400,400);
glutCreateWindow("Demo window");
glutDisplayFunc(renderScene);
glutMainLoop();
return 1;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question