命令行有效,Makefile 中的相同命令不起作用
commandline works, same command in Makefile doesn't
我完成了本教程,了解如何安装Mesa(OpenGL)。一切都按照描述工作。但是当我尝试将运行良好的构建命令放入 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 而不是教程中的 Mint。
我做错了什么?
您没有将 OpenGl 库传递给链接器。您应该键入l
而不是I
:
all:
gcc main.c -lglut -lGL -lGLEW -lGLU -o OpenGLExample
您还应该传递编译器可以找到 OpenGL 头文件的目录,这可以通过 -I
来完成,并且可能还有一个选项(或多个选项),指定链接器应该在哪里查找库(-L)
。
相关文章:
- g++ -I 和 -L 命令来查找不起作用的 .hpp 文件
- bcdedit 文件输出不起作用,但其他命令可以
- 我的Arduino串行命令行不起作用,我不知道为什么
- "pm install"命令对安卓不起作用
- 使用系统命令时发送输入不起作用
- Python:使用<cstdio>时与c ++命令行程序的通信不起作用
- 在命令中运行 cmake 'make'不起作用
- Visual Studio 命令行不起作用
- "iw"命令在Qt Ubuntu 14.04的Qprocess中不起作用
- 二维矢量的C++Insert命令不起作用
- xcopy 命令通过C++ 'system'不起作用
- 命令行有效,Makefile 中的相同命令不起作用
- 执行命令在Geany(Windows 10)中不起作用
- 使用 AssocQueryString 从 32 位应用程序获取 64 位应用程序命令,但不起作用
- 系统命令在C++中不起作用
- 使用C++的SQLite中的INSERT INTO命令不起作用
- 命令'cin'和'cout'不起作用
- Eclipse C++ 项目创建向导中的"Finish"命令不起作用
- "if" 和"else if"命令在 C++ 中不起作用
- 使用正则表达式和 sed 命令替换C++代码中的' *'指针不起作用