C: SDL 代码在 ubuntu 终端中编译,但在 vscode 中不编译
当我在 ubuntu 终端中编译代码时,它可以完美编译,但是当我在 VSCode 集成终端中执行命令时,它会给我一个错误:
main.c:1:10: fatal error: no such file or directory
这是我使用的命令:
$ gcc main.c $(sdl2-config --cflags --libs) -o prog
这是我的代码:
#include <SDL.h>
#include <stdio.h>
int main(int argc, char **argv) {
SDL_Window *window = NULL;
if(SDL_Init(SDL_INIT_VIDEO) != 0) {
SDL_Log("ERROR: SDL Initialization > %s\n", SDL_GetError());
exit(EXIT_FAILURE);
}
// program execution
window = SDL_CreateWindow("SDL2 Window", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, 0);
if(window == NULL) {
SDL_Log("ERROR: SDL Initialization > %s\n", SDL_GetError());
exit(EXIT_FAILURE)
}
SDl_Quit();
return EXIT_SUCCESS;
}
When I compile my code in the ubuntu terminal, it compiles perfectly, but when I execute the command in the VSCode integrated terminal, it gives me an error:
main.c:1:10: fatal error: no such file or directory
here's the command I use:
$ gcc main.c $(sdl2-config --cflags --libs) -o prog
and here is my code:
#include <SDL.h>
#include <stdio.h>
int main(int argc, char **argv) {
SDL_Window *window = NULL;
if(SDL_Init(SDL_INIT_VIDEO) != 0) {
SDL_Log("ERROR: SDL Initialization > %s\n", SDL_GetError());
exit(EXIT_FAILURE);
}
// program execution
window = SDL_CreateWindow("SDL2 Window", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, 0);
if(window == NULL) {
SDL_Log("ERROR: SDL Initialization > %s\n", SDL_GetError());
exit(EXIT_FAILURE)
}
SDl_Quit();
return EXIT_SUCCESS;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论