6

我正在为 ruby​​ 开发 C 扩展,但我需要包含IOBluetooth框架中的标头,特别是:

#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 以便库静态链接;仍然遇到同样的错误,但这次是在链接时。

奇怪的是,have_header在我的extconf.rb文件中发现这些头文件很好。

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

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问题有关?将调查并发布结果

4

2 回答 2

1

Make sure you included

-framework Foundation System/Library/Frameworks/IOBluetooth.framework/IOBluetooth

In your makeFile. Be sure you have the framework in the right directory. But if you can compile it, link it, your IOBluetooth seems now in your binary.

By the way you are trying to access a pointer at address 0x02, this is what creating the crash. I'm not sure it's related to IOBluetooth anymore

于 2012-10-22T09:09:52.623 回答
1

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

于 2012-10-17T18:38:15.343 回答