简体   繁体   English

C编译错误(无此文件或目录,编译终止)

[英]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 ,而不是1l ):

$ 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.

相关问题 如何解决致命错误jvmti.h没有这样的文件或目录编译终止c代码ubuntu? - how to fix fatal error jvmti.h No such file or directory compilation terminated c code ubuntu? 致命错误:libavcodec / avcodec.h没有这样的文件或目录编译终止 - fatal error: libavcodec/avcodec.h no such file or directory compilation terminated 致命错误:editline/readline.h:没有这样的文件或目录编译终止 - fatal error: editline/readline.h: No such file or directory compilation terminated 致命错误:opencv / cvtypes.h:没有终止此类文件或目录的编译 - fatal error: opencv/cvtypes.h: No such file or directory compilation terminated C编译错误-#include“ cmakeconfig.h”-没有这样的文件或目录 - C compile error - #include “cmakeconfig.h” - No such file or directory 编译错误:“stdint.h:没有那个文件或目录” - Compilation error: “stdint.h: No such file or directory” cc1.exe:致命错误:begginer.c:权限被拒绝编译终止 - cc1.exe: fatal error: begginer.c: Permission denied compilation terminated 在编译命令中包含头文件时出现编译错误 - Compilation error while including header file in compile command Ubuntu 不会编译 C 文件,错误“<drfftw_mpi.h> : 无此文件或目录” - Ubuntu won't compile a C file, error "<drfftw_mpi.h>: No such file or directory" 错误:没有这样的文件或目录 - C - Error: no such file or directory - C
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM