我通过this教程了解如何安装Mesa(OpenGL)。一切都如上所述。但是,当我尝试将完美工作的构建命令放入makefile时,它不会。命令行工作,在Makefile中同样的命令不是
这是我的makefile:
all:
gcc -lglut -IGL -IGLEW -IGLU main.c -o OpenGLExample
如果我输入make,我得到:
gcc -lglut -IGL -IGLEW -IGLU main.c -o OpenGLExample
/tmp/ccKVrQAu.o:main.c:function renderFunction: error: undefined reference to 'glClearColor'
/tmp/ccKVrQAu.o:main.c:function renderFunction: error: undefined reference to 'glClear'
/tmp/ccKVrQAu.o:main.c:function renderFunction: error: undefined reference to 'glColor3f'
/tmp/ccKVrQAu.o:main.c:function renderFunction: error: undefined reference to 'glOrtho'
/tmp/ccKVrQAu.o:main.c:function renderFunction: error: undefined reference to 'glBegin'
/tmp/ccKVrQAu.o:main.c:function renderFunction: error: undefined reference to 'glVertex2f'
/tmp/ccKVrQAu.o:main.c:function renderFunction: error: undefined reference to 'glVertex2f'
/tmp/ccKVrQAu.o:main.c:function renderFunction: error: undefined reference to 'glVertex2f'
/tmp/ccKVrQAu.o:main.c:function renderFunction: error: undefined reference to 'glVertex2f'
/tmp/ccKVrQAu.o:main.c:function renderFunction: error: undefined reference to 'glEnd'
/tmp/ccKVrQAu.o:main.c:function renderFunction: error: undefined reference to 'glFlush'
collect2: ld returned 1 exit status
make: *** [all] Error 1
我使用Ubuntu,而不是薄荷作为教程。
这是什么,我做错了?
我很惊讶,第一次调用工作。您必须将'-lXXX'链接器标志放在命令行的末尾。 – 2013-10-17 15:41:30
@ H2CO3或至少在使用它们的任何源文件之后。 (我认为你可以在'-l'之后放置'-I'选项,没有问题。) –
@JamesKanze是的,的确如此。 – 2013-10-17 16:41:23