gpt4 book ai didi

在 MAC 上编译 SDL

转载 作者:行者123 更新时间:2023-12-04 22:46:22 24 4
gpt4 key购买 nike

#include "ffmpeg/libavcodec/avcodec.h"

#include "ffmpeg/libavformat/avformat.h"

#include "ffmpeg/libswscale/swscale.h"
#include "ffmpeg/libswscale/rgb2rgb.h"
#include "ffmpeg/libswscale/swscale_internal.h"

#include <stdio.h>

#ifdef __MINGW32__
#undef main /* Prevents SDL from overriding main() */
#endif

#include "SDL.framework/Headers/SDL.h"
#include "SDL.framework/Headers/SDL_thread.h"

使用以下命令编译:
gcc -o t1 tutorial01.c -lswscale -lavutil -lavformat -lavcodec -lz -lavutil -lm -framework SDL

但我得到这个错误:
Undefined symbols:
"_main", referenced from:
start in crt1.10.6.o
(maybe you meant: _SDL_main)
ld: symbol(s) not found
collect2: ld returned 1 exit status

通过谷歌搜索,如果我尝试添加:#include "SDLMain.h"它有严重的动脉瘤。

最佳答案

将您的编译行更改为:

gcc -o t1 tutorial01.c -lswscale -lavutil -lavformat -lavcodec -lz -lavutil -lm `sdl-config --cflags --libs`

在我的mbp上, sdl-config --cflags --libs输出:
-I/usr/local/include/SDL -D_GNU_SOURCE=1 -D_THREAD_SAFE
-L/usr/local/lib -lSDLmain -lSDL -Wl,-framework,Cocoa

关于在 MAC 上编译 SDL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4019892/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com