C Compile Error (No such file or directory, compilation terminated)

自闭症网瘾萝莉.ら 提交于 2019-12-25 12:19:18

问题


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

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!


回答1:


First of all you need to check that there is a glut.h file, in a GLUT folder.

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

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

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



回答2:


USER DEFINED HEADERS SYNTAX IS #include "name of file.h " ....... there is no "<" or ">"....because that just asks the compiler to check in its directories were all headers are stored ...wereas " " ask compiler to check current directory....and of course make sure the header is defined in the same directory as ur main.c



来源:https://stackoverflow.com/questions/22377762/c-compile-error-no-such-file-or-directory-compilation-terminated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!