在 Mac 上编译 SDL 游戏
我有一台 Mac,我正在尝试编译我的项目。 wiki 上的标准: g++ sdl.cpp -lSDLmain -lSDL -framework Cocoa 似乎不起作用,它返回找不到 -lSDL 和 -lSDLmain 。任何帮助将不胜感激。
I have a mac and I am trying to compile my projects. The standard on the wiki: g++ sdl.cpp -lSDLmain -lSDL -framework Cocoa does not seem to be working it returns that it cannot find -lSDL and -lSDLmain. Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你明白这些标志的含义吗?链接器正在寻找库 SDL 和 SDLmain,它们是否安装在您的计算机上?
Do you understand the meaning of the flags? The linker is looking for the libraries SDL and SDLmain, are they setup on your machine?
对我来说,解决方案如下:
既然已经创建了目标文件,我们可以使用此解决方案:
此解决方案假设您已将 SDL_image、SDL_mixer、SDL_ttf 和 SDL_net 框架安装在“/Library/Frameworks/”目录中。
由于这很难手动尝试,并且解决方案有点混乱,因此最好简单地编写一个脚本来为您完成所有这些工作。
“-I”(大写 i)标志告诉编译器在哪里查找标头。 “-L”标志告诉编译器在哪里寻找库。 “-l”(小写 L)标志告诉编译器要使用哪些库。 “-framework”标志的行为基本上类似于“-l”(小写 L)标志。
For me the solution is as follows:
Now that the object file has been created, we can use this solution:
This solution assumes that you have the SDL_image, SDL_mixer, SDL_ttf, and SDL_net frameworks installed in the '/Library/Frameworks/' directory.
Since this is difficult to attempt by hand, and the solution is a little messy, it's better to simply write a script to do all of this for you.
The '-I' (capital i) flag tells the compiler where to look for headers. The '-L' flag tells the compiler where to look for libraries. The '-l' (lower case L) flag tells the compiler which libraries to use. The '-framework' flag basically behaves like a '-l' (lower case L) flag.