【发布时间】:2021-04-23 16:12:27
【问题描述】:
如何在不使用 Cmake 的情况下在 linux 命令行中使用 gcc 编译 sdl 项目?
编辑;
gcc SDLGAME.c pkg-config --cflags --libs sdl2
但我得到了错误。
gcc: error: Pkg-config: No such file or directory
gcc: error: sdl2: No such file or directory
gcc: error: unrecognized command line option ‘--cflags’
gcc: error: unrecognized command line option ‘--libs’; did you mean ‘--libs=’?
@HolyBlackCat
源代码--->>
#include <stdio.h>
#include <SDL2/SDL.h>
int main(int argc,char *argv[])
{
if (SDL_Init(SDL_INIT_VIDEO) !=0)
{
printf("error SDL");
return 0;
}
SDL_Window* win=SDL_CreateWindow("Game",
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
500,500,0);
return 0;
}
我得到这个错误--->>
error: XDG_RUNTIME_DIR not set in the environment.
error SDL
【问题讨论】:
-
我做不到
-
"couldn't do it" 不是问题描述。
-
在 Linux 上使用
pkg-config工具和软件包,使用gcc -Wall -Wextra -g SDLGAME.c $(pkg-config --cflags --libs sdl2) -o sdlgame-binary编译您的SDLGAME.c文件,然后使用 GDB 调试器