[英]How do I install SDL2 on mac using C preferably without X-Code?
I am using C and building a game I have tried every forum out there most seem to be in C++ and I would like to use SDL2 with C. I am using gcc compiler and the furthest I got was for it to compile with Gcc but no window would appear.我正在使用 C 并构建一个游戏我已经尝试过每个论坛似乎都在 C++ 中,我想将 SDL2 与 C 一起使用。我使用的是 gcc 编译器,我得到的最远的是用 Gcc 编译但没有窗口会出现。 Not code because grabbed it from a tutorial.不是代码,因为它是从教程中获取的。 I have tried with brew and the framework.我已经尝试过 brew 和框架。
Could Somebody please walk me through the install process to get it working either with gcc or xcode有人可以指导我完成安装过程以使其与 gcc 或 xcode 一起工作吗
EDIT: On Catalina 10.15.6编辑:在 Catalina 10.15.6 上
thanks谢谢
Okay, I figured it Out, those who are also having trouble you can here is my solution,好的,我想通了,那些也遇到麻烦的人可以在这里是我的解决方案,
You download and install the framework into Library/Frameworks
then once you are done that you will be able to compile using gcc with this command您将框架下载并安装到Library/Frameworks
然后一旦完成,您就可以使用 gcc 使用此命令进行编译
gcc main.c -o run -I/Library/Frameworks/SDL2.framework/Headers -F/Library/Frameworks -framework SDL2 -I/Library/Frameworks/SDL2_image.framework/Headers -F/Library/Frameworks -framework SDL2_image
How ever as I mentioned before you can get the code to compile without a window appearing so here is the solution full credit to the forums and the User Sjr正如我之前提到的,您可以在不出现窗口的情况下编译代码,所以这里的解决方案完全归功于论坛和用户 Sjr
https://discourse.libsdl.org/t/sdl2-compiles-but-doent-open-a-window-when-run/26867 https://discourse.libsdl.org/t/sdl2-compiles-but-doent-open-a-window-when-run/26867
and here is a link to how I got the compiler to work这是我如何让编译器工作的链接
https://youtu.be/BCcvwoIOHVI https://youtu.be/BCcvwoIOHVI
The compile command is different so look in the comments the reply by ikokujin to the comment by Phraggers with a couple edits by me to include gcc -o run
编译命令是不同的,所以在评论中查看 ikokujin 对 Phraggers 评论的回复,并由我进行了一些编辑以包括gcc -o run
Hope this info help's everyone who was stuck on this in their sdl2 project on Mac.希望这些信息可以帮助在 Mac 上的 sdl2 项目中陷入困境的每个人。
Thanks, Winter_Ice谢谢,Winter_Ice
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.