theos 创建一个 dylib,而不是调整

发布于 2024-12-04 16:58:06 字数 1050 浏览 2 评论 0原文

我注意到 theos 可以构建库并生成 dylib,我尝试了简单的代码,例如

static UIAlertView *alert_view;
static void showAlert() {
    alert_view = [[UIAlertView alloc] initWithTitle:@"Welcome" 
                                                    message:@"Welcome to your iPhone Brandon!" 
                                                   delegate:nil 
                                          cancelButtonTitle:@"Thanks" 
                                          otherButtonTitles:nil];
    [alert_view show];
    [alert_view release];
}

make 之后我得到了一个 dylib,但我尝试构建一个测试项目来使用这个 dylib,失败了。 我的测试代码就像

void* sdl_library = dlopen("/tmp/AlertDylib.dylib", RTLD_LAZY);
if(sdl_library == NULL) {
    NSLog(@"fail load");
} else {
    // use the result in a call to dlsym
    void* showAlert = dlsym(sdl_library,"showAlert");
    if(showAlert == NULL) {
        NSLog(@"fail got function");
    } else {
        // cast initializer to its proper type and use
    }
}

我确定我将 dylib 文件放在 /tmp/ 下,但日志显示“功能失败”,我错过了任何步骤吗?

I notice theos could build library and produce dylib, I try the simple code like

static UIAlertView *alert_view;
static void showAlert() {
    alert_view = [[UIAlertView alloc] initWithTitle:@"Welcome" 
                                                    message:@"Welcome to your iPhone Brandon!" 
                                                   delegate:nil 
                                          cancelButtonTitle:@"Thanks" 
                                          otherButtonTitles:nil];
    [alert_view show];
    [alert_view release];
}

after make I got a dylib, but I try to build a test project to use this dylib, failed.
My test code like

void* sdl_library = dlopen("/tmp/AlertDylib.dylib", RTLD_LAZY);
if(sdl_library == NULL) {
    NSLog(@"fail load");
} else {
    // use the result in a call to dlsym
    void* showAlert = dlsym(sdl_library,"showAlert");
    if(showAlert == NULL) {
        NSLog(@"fail got function");
    } else {
        // cast initializer to its proper type and use
    }
}

I'm sure I put dylib file under /tmp/, but log said "fail got function", any steps I missed?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文