在eclipse上编译c ++ glut项目时未定义的错误引用

时间:2017-02-05 11:43:22

标签: c++ eclipse glut

在尝试在Eclipse上编译c ++ glut项目时,我得到了对所有OpenGL代码的“未定义引用”错误。

操作系统:Xubuntu 16.04 64位

Eclipse版本:NEON.2

在Eclipse上,我通过转到项目属性然后转到“C / C ++ Build”>>来链接库。设置>> Cross GCC Compiler>>包括。然后是“添加...”按钮,输入过剩

c ++ glut例子:

#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;
}
终端上的

错误: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

在Eclipse中,错误是:

eclipse errors when compiling glut code

0 个答案:

没有答案