0

I get an "undefined reference to" error to all the OpenGL codes when trying to compile a c++ glut project on Eclipse.

OS: Xubuntu 16.04 64bit

Eclipse version: NEON.2

On Eclipse, I linked the library by going to the project properties and then to "C/C++ Build" >> settings >> Cross GCC Compiler >> Includes. And then the "Add..." Button and typing glut.

c++ glut example:

#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.5,0.0,0.0);
        glVertex3f(0.0,0.5,0.0);
    glEnd();

        glutSwapBuffers();
}

int main(int argc, char **argv) {

    // init GLUT and create Window
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
    glutInitWindowPosition(100,100);
    glutInitWindowSize(320,320);
    glutCreateWindow("Lighthouse3D - GLUT Tutorial");

    // register callbacks
    glutDisplayFunc(renderScene);

    // enter GLUT event processing cycle
    glutMainLoop();

    return 1;
}

Error on terminal: g++ main.cpp -o main -lglut

    enter cod/usr/bin/ld: /tmp/cc4XI1YG.o: undefined reference to symbol 'glVertex3f'
//usr/lib/x86_64-linux-gnu/mesa/libGL.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

In Eclipse, the errors are:

eclipse errors when compiling glut code

0 Answers0