简体   繁体   English

sdl_ttf iOS错误的入口点

[英]sdl_ttf iOS wrong entry point

I have been trying out SDL for iOS, and it has been going smoothly until I added sdl_ttf to the mix. 我一直在尝试iOS的SDL,并且一直进行得很顺利,直到我将sdl_ttf添加到了混合中。 The only output that I would get was 我唯一会得到的输出是

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

Upon googling, I found this SO question from someone who had the same problem as me: SDL2_ttf won't run on ios 谷歌搜索后,我从一个与我有相同问题的人那里发现了一个SO问题: SDL2_ttf无法在ios上运行

It seems that a different main (one inside sdl_ttf) is being run and is producing the output. 似乎正在运行其他主程序(sdl_ttf中的一个主程序)并正在生成输出。

  1. A commenter on the post I mentioned said "I would guess you included apinames.c in your project from the tools directory and that main is what is getting run". 我提到的帖子的评论者说:“我想您可能会在tools目录中将apinames.c包含在项目中,而主要的是正在运行的内容。” What is the tools directory? 什么是工具目录? How would I fix that? 我该如何解决?

  2. How would I change the entry point of the Xcode project to my main.cpp? 如何将Xcode项目的入口点更改为main.cpp?

Thanks for any advice. 感谢您的任何建议。

I would have to actually see your project to answer #1 (did you look at your "compiled Sources" for apinames.c?), but maybe that will be irrelevant if I answer #2. 我将不得不实际看到您的项目来回答#1(您是否在看apinames.c的“已编译源代码”?),但是如果我回答#2,也许那将是不相关的。

If you look at the SDL_main.h source file you will see: 如果查看SDL_main.h源文件,将会看到:

#elif defined(__IPHONEOS__) /* On iOS SDL provides a main function that creates an application delegate and starts the iOS application run loop. #elif defined(__ IPHONEOS__)/ *在iOS上,SDL提供了一个主要功能,该功能创建应用程序委托并启动iOS应用程序运行循环。

See src/video/uikit/SDL_uikitappdelegate.m for more details. 有关更多详细信息,请参见src / video / uikit / SDL_uikitappdelegate.m。 */ * /

#define SDL_MAIN_NEEDED #定义SDL_MAIN_NEEDED

turns out you can subclass SDLUIKitDelegate and force SDL to instantiate it by creating a category like this: 事实证明,您可以创建SDLUIKitDelegate子类,并通过创建如下类别来强制SDL对其进行实例化:

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

you will want to look at the source for SDLUIKitDelegate so you can get a feel for what you are messing with, but my app just overrides application:didFinishLaunchingWithOptions: like this: 您将需要查看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];
}

Is this close enough for the entry point for you? 对于您的入口点来说,这个距离足够近了吗? Or do you really need main() ? 还是真的需要main()吗? It would mean having to do all the SDL setup yourself (which can change between SDL revisions). 这意味着必须自己完成所有SDL设置(可以在SDL版本之间进行更改)。

Also note that your main() should get redefined as SDL_main and should get called at some point early on (if my memory serves). 还要注意,您的main()应该被重新定义为SDL_main并且应该在某个时候被调用(如果我的内存SDL_main话)。

Drag to re-order your frameworks within "Link Binary With Libraries" found in your xcode build target under "Build Phases". 拖动以在xcode构建目标的“构建阶段”下的“链接二进制文件与库”中对框架进行重新排序。 Ensure that SDL2.framework (or whatever you are using) is above SDL2_image.framework. 确保SDL2.framework(或您使用的任何文件)在SDL2_image.framework之上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM