gpt4 book ai didi

objective-c - 将 Cocoa header 链接到 ruby​​ C 扩展

转载 作者:数据小太阳 更新时间:2023-10-29 07:07:52 24 4
gpt4 key购买 nike

我正在为 ruby​​ 开发一个 C 扩展,但我需要包含来自 IOBluetooth 框架的 header ,特别是:

#import <IOBluetooth/objc/IOBluetoothDeviceInquiry.h>
#import <IOBluetooth/IOBluetoothUserLib.h>

一切都编译正常,但在运行时,扩展错误:

path/to/file.rb:1:in `require_relative': dlopen(/path/to/extension.bundle, 9):
Symbol not found: _OBJC_CLASS_$_IOBluetoothDeviceInquiry (LoadError)

我相当确定这与未包含在链接过程中的框架有关,但我不确定原因。任何帮助将不胜感激

extconf.rb:

# Loads mkmf which is used to make makefiles for Ruby extensions
require 'mkmf'

# Give it a name
extension_name = 'bluetooth'

dir_config(extension_name)

create_makefile(extension_name, 'bluetooth')

生成的 MakeFile: http://paste.wilhall.com/25

更新:我修改了 Makefile 以便库静态链接;仍然遇到同样的错误,但这次是在链接时。

奇怪的是,我的 extconf.rb 文件中的 have_header 可以正常找到这些头文件。

更新:我从系统日志文件中提取了以下内容:

Process:         ruby [951]
Path: /usr/local/bin/ruby
Identifier: ruby
Version: 0
Code Type: X86-64 (Native)
Parent Process: bash [468]
User ID: 501

Date/Time: 2012-10-17 14:06:57.425 -0400
OS Version: Mac OS X 10.8.1 (12B19)
Report Version: 10

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_BAD_ACCESS (SIGABRT)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000010

如果我没记错的话,EXC_BAD_ACCESS (SIGABRT) 通常与 GC 问题有关?将调查并发布结果

最佳答案

这看起来太简单了,所以我可能会离开,但从你发布的内容来看它看起来是正确的。看起来问题不在于 header ,而是您没有链接 IOBluetooth 框架本身。您是否在任何地方指定了诸如 -framework IOBluetooth 之类的内容?

关于objective-c - 将 Cocoa header 链接到 ruby​​ C 扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12887639/

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