[英]C Compile Error (No such file or directory, compilation terminated)
I'm on Windows trying to learn some OpenGL. 我在Windows上尝试学习一些OpenGL。 I Installed mingw and have a test file.
我安装了mingw,并有一个测试文件。 I put my test.c file in a glut folder, which contains glut files such as the glut32.dll and library file.
我将test.c文件放在glut文件夹中,其中包含glut文件,例如glut32.dll和库文件。 I used mingw in cmd to run the file using this:
我在cmd中使用mingw使用以下命令运行文件:
gcc opengl.c -o opengl -lGL -lGLU -lglut
And I got this error: 我得到了这个错误:
opengl.c:1:23 fatal error: GLUT/glut.h: No such file or directory
#include <GLUT/glut.h>
compilation terminated. 编译终止。
Not sure what I'm doing wrong, anybody know? 不知道我在做什么错,有人知道吗? Thanks!
谢谢!
First of all you need to check that there is a glut.h
file, in a GLUT
folder. 首先,您需要检查
GLUT
文件夹中是否存在glut.h
文件。
Then you tell the compiler where to find it using the -I
command-line option (note, it's capital i
, not 1
or l
): 然后,使用
-I
命令行选项告诉编译器在哪里可以找到它(请注意,它的大小写是i
,而不是1
或l
):
$ gcc -I/path/to/folder opengl.c -o opengl -lGL -lGLU -lglut
In the command above, replace /path/to/folder
to the folder where the GLUT
folder is. 在上面的命令中,将
/path/to/folder
替换为GLUT
文件夹所在的文件夹。
You might also need to tell the linker where the libraries are, which is done with the -L
option: 您可能还需要告诉链接程序这些库在哪里,这是通过
-L
选项完成的:
$ gcc -I/path/to/folder opengl.c -o opengl -L/path/to/libs -lGL -lGLU -lglut
用户定义的头文件语法为#include“ file.h的名称” .......不存在“ <”或“>” ....,因为只是要求编译器检查其目录中是否所有头文件都是存储的... wereas“”让编译器检查当前目录。...当然,请确保标头与ur main.c在同一目录中定义
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.