C编译错误(无此类文件或目录,编译终止) [英] C Compile Error (No such file or directory, compilation terminated)

查看:1380
本文介绍了C编译错误(无此类文件或目录,编译终止)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows上试图学习一些OpenGL。我安装mingw并有一个测试文件。
我把我的test.c文件在一个glut文件夹,其中包含glut文件,如glut32.dll和库文件。
我使用mingw在cmd中使用这个运行文件:

I'm on Windows trying to learn some OpenGL. I Installed mingw and have a test file. I put my test.c file in a glut folder, which contains glut files such as the glut32.dll and library file. I used mingw in cmd to run the file using this:

gcc opengl.c -o opengl -lGL -lGLU -lglut

我收到此错误:

opengl.c:1:23 fatal error: GLUT/glut.h: No such file or directory
#include <GLUT/glut.h>

编译已终止。

我做错了,任何人知道?谢谢!

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.

然后你告诉编译器在哪里可以找到它使用 -I 命令行选项(注意,它的资本 i ,而不是 1 l ):

Then you tell the compiler where to find it using the -I command-line option (note, it's capital i, not 1 or l):

$ gcc -I/path/to/folder opengl.c -o opengl -lGL -lGLU -lglut

在上面的命令中,将 / path /替换为/ folder GLUT 文件夹所在的文件夹。

In the command above, replace /path/to/folder to the folder where the GLUT folder is.

您还可能需要告诉链接器库在哪里,这是通过 -L 选项完成的:

You might also need to tell the linker where the libraries are, which is done with the -L option:

$ gcc -I/path/to/folder opengl.c -o opengl -L/path/to/libs -lGL -lGLU -lglut

这篇关于C编译错误(无此类文件或目录,编译终止)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆