sdl_ttf iOS错误的入口点

sdl_ttf iOS wrong entry point

本文关键字:入口 错误 iOS ttf sdl      更新时间:2023-10-16

我一直在尝试适用于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赢了';t在ios 上运行

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

  1. 我提到的帖子上的一位评论者说:"我猜你的项目中包含了tools目录中的apinames.c,而这个main就是正在运行的内容"。工具目录是什么?我该怎么解决?

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

谢谢你的建议。

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

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

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

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

#定义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,并且应该在早期的某个时候被调用(如果我有记忆的话)。

拖动以在"构建阶段"下的xcode构建目标中的"链接二进制与库"中重新排序框架。确保SDL2.framework(或您正在使用的任何东西)高于SDL2_image.framework.