我尝试:
g++ -Wall affichage.c -o game -D_REENTRANT -I/usr/local/Cellar/sdl/1.2.15_1/SDL
但是我有这个错误:
Undefined symbols for architecture x86_64:
"_SDL_EnableKeyRepeat", referenced from:
chargement_objets(img*, img*) in affichage-50cd48.o
"_SDL_Flip", referenced from:
affiche_menu(img, img) in affichage-50cd48.o
_SDL_main in affichage-50cd48.o
gcc Version :
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin19.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
sdl安装在:/usr/local/Cellar/sdl/1.2.15_1
Mac OS Catalina
答案 0 :(得分:0)
未定义的符号错误在链接时发生。
因此,就像将头文件查找路径指定为-I/usr/local/Cellar/sdl/1.2.15_1/SDL
(在编译时会有所帮助)一样,将库搜索路径指定为-L/usr/local/Cellar/sdl/1.2.15_1/SDL/lib
或诸如此类的指向正确路径的东西。您可能还需要添加类似-lSDL
之类的内容,以指定所使用的函数所在的库。请注意,-l SDL 表示针对lib SDL 的链接。a