gpt4 book ai didi

c - 如何使用 gcc 修复 SDL2 编译错误?

转载 作者:行者123 更新时间:2023-11-30 16:11:08 24 4
gpt4 key购买 nike

当我使用 gcc 编译代码时,链接问题不断出现。

"/usr/local/include/sdl2_ttf/2.0.15/include/SDL2/SDL_ttf.h:34:10: fatal error: SDL.h: No such file or directory
34 | #include "SDL.h"
| ^~~~~~~
compilation terminated."

我使用了编译命令:

gcc main.c -I /usr/local/include/sdl2/2.0.10/include -L /usr/local/include/sdl2/2.0.10/lib -I /usr/local/include/sdl2_ttf/2.0.15/include -L /usr/local/include/sdl2_ttf/2.0.15/lib -lSDL2 -lSDL2_ttf

实际上是<SDL2/SDL.h>已链接成功。但是,我认为出现问题是因为没有 SDL.h文件在 SDl2_ttf/include文件。我该如何解决这个问题?非常感谢。

最佳答案

使用包含指令

#include <SDL2/SDL.h>

并使用

编译您的程序
gcc main.c $(sdl-config --cflags) $(sdl-config --libs)

关于c - 如何使用 gcc 修复 SDL2 编译错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58686197/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com