0

我一直在尝试适用于 iOS 的 SDL,它一直很顺利,直到我将 sdl_ttf 添加到组合中。我得到的唯一输出是

apinames 0.1: extract FreeType API names from header files

this program is used to extract the list of public FreeType API
functions. It receives the list of header files as argument and
generates a sorted list of unique identifiers

usage: apinames header1 [options] [header2 ...]

options:   -      : parse the content of stdin, ignore arguments
           -v     : verbose mode, output sent to standard error
           -oFILE : write output to FILE instead of standard output
           -dNAME : indicate DLL file name, 'freetype.dll' by default
           -w     : output .DEF file for Visual C++ and Mingw
           -wB    : output .DEF file for Borland C++
           -wW    : output Watcom Linker Response File

谷歌搜索后,我从和我有同样问题的人那里找到了这个 SO 问题:SDL2_ttf won't run on ios

似乎正在运行一个不同的 main(一个在 sdl_ttf 内)并产生输出。

  1. 我提到的帖子的评论者说:“我猜你在工具目录中的项目中包含了 apinames.c,而 main 就是正在运行的东西”。什么是工具目录?我将如何解决这个问题?

  2. 如何将 Xcode 项目的入口点更改为我的 main.cpp?

感谢您的任何建议。

4

2 回答 2

0

我必须实际看到您的项目才能回答#1(您是否查看了 apinames.c 的“编译源”?),但如果我回答#2,这可能无关紧要。

如果您查看 SDL_main.h 源文件,您将看到:

#elif defined(__IPHONEOS__) /* 在 iOS 上,SDL 提供了一个 main 函数,用于创建应用程序委托并启动 iOS 应用程序运行循环。

有关更多详细信息,请参阅 src/video/uikit/SDL_uikitappdelegate.m。*/

#define SDL_MAIN_NEEDED

事实证明,您可以SDLUIKitDelegate通过创建这样的类别来继承并强制 SDL 实例化它:

@implementation SDLUIKitDelegate (MyDelegate)
+ (NSString *)getAppDelegateClassName
{
    //override this SDL method so an instance of our subclass is used
    return @"MyDelegateClass";
}
@end

您将需要查看源代码,SDLUIKitDelegate以便了解您正在搞砸的内容,但我的应用程序只是application:didFinishLaunchingWithOptions:像这样覆盖:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    AddLogger(createAppleLogger());
    [self setupWrapper];

    // Notice how we call super implementation so SDL can finish its setup
    return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

这对于您来说是否足够接近入口点?还是你真的需要main()?这意味着必须自己进行所有 SDL 设置(这可以在 SDL 版本之间更改)。

另请注意,您main()应该被重新定义为SDL_main并且应该在早期的某个时候被调用(如果我没记错的话)。

于 2014-10-30T13:40:45.157 回答
0

在“Build Phases”下的 xcode 构建目标中找到的“Link Binary With Libraries”中拖动以重新排序您的框架。确保 SDL2.framework(或您正在使用的任何东西)在 SDL2_image.framework 之上。

于 2015-06-24T12:21:54.443 回答