我通过 brew 在我的 mac 上安装了 SDL,但我无法包含它! 这是我太简单的代码:
#include <SDL.h>
int main(){
return 0;
}
用cc编译时,CC找不到SDL.h 我发现 brew install SDL in Cellar 但 cc 没有检查这个文件夹 你能帮帮我吗?
最佳答案
我知道这篇文章已有 9 个月了,但如果有人在互联网上的某个地方试图找出如何在 mac 上使用 SDL,请按照此操作。
SDL 网站 (V2) 上的 DL .dmg 文件。
将SDL2.framework放入/Library/Frameworks
在您的代码中:
#include <SDL.h>
并使用这些标志进行编译:
`sdl-config --cflags --libs`
例如:
gcc test.c `sdl-config --cflags --libs`
使用这个简单的代码来查看它的工作情况:
#include <stdlib.h>
#include <stdio.h>
#include <SDL/SDL.h>
int main( int argc, char *argv[ ] )
{
SDL_Surface *screen;
if( SDL_Init( SDL_INIT_VIDEO ) == -1 )
{
printf( "Can't init SDL: %s\n", SDL_GetError( ) );
return EXIT_FAILURE;
}
atexit( SDL_Quit );
screen = SDL_SetVideoMode( 640, 480, 16, SDL_HWSURFACE );
if( screen == NULL )
{
printf( "Can't set video mode: %s\n", SDL_GetError( ) );
return EXIT_FAILURE;
}
SDL_Delay( 3000 );
return EXIT_SUCCESS;
}
关于sdl - 将 SDL 添加到我的路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18425812/