C: SDL 代码在 ubuntu 终端中编译,但在 vscode 中不编译

发布于 2025-01-09 07:42:43 字数 942 浏览 2 评论 0原文

当我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文