c - 启用在 macbook 上编译 sdl 1.2 项目
问题描述
我试试这个:
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 卡特琳娜
解决方案
未定义符号错误发生在链接时。因此,就像将标头查找路径指定为 一样-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的链接
推荐阅读
- c++ - OpenGL:在给定包含总光的叉积的情况下,如何渲染单个 RGB 值?
- sql - Informix - 带有合并的 where 子句
- excel - 在 2 列上使用 Target.Value 验证智利 RUT
- tableau-api - ELSEIF 在 THEN 中有 2 个两个选项
- unity3d - 使用 ARCamera(Vuforia,Unity)在均匀背景表面上丢失模型
- arrays - Ada:任务数组
- reactjs - onChange 在 select for react 中不起作用
- c++-amp - 强调 GPU 时的 C++ AMP 部门怪癖
- python - 如何进行简单的长度验证
- azure - 将 .Net Core 控制台应用程序作为 Azure Webjob 运行时与 Azure SQL 数据库的连接错误