Undefined symbols for architecture x86_64

A Xcode beginners' question:

It is my first experience with Xcode 4.6.3.

I am trying to write a very simple console program that searches for paired BT devices and print them to a NSLog.

The build with the error:

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_IOBluetoothDevice", referenced from:
      objc-class-ref in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I searched like crazy. The common problem should be a reference to a file of which only the header files are imported and no implementation (*.m-file) is found by the linker. The IOBluetooth library is however a standard Framework like the Foundation Framework.

What am I missing in my above statement?

I also have tried building it for a 32-bit machine (build fails again). It is clearly a linker error, however I hove no idea to what is relates except that there is an issue with finding the implementation for IOBluetoothDevice on both x86 and x64 architecture while the header files a from a standard included Framework called IOBluetooth?

For your information my main code "main.m" being

#import <Foundation/Foundation.h>
#import <IOBluetooth/objc/IOBluetoothDevice.h>          // Note the import for bluetooth
#import <IOBluetooth/objc/IOBluetoothDeviceInquiry.h>   // Note the import for bluetooth


int main(int argc, const char * argv[])
{
    @autoreleasepool {
        IOBluetoothDevice *currentDevice;
        NSArray *devices = [ IOBluetoothDevice pairedDevices];


        for (id currentDevice in devices){
          NSLog(@"%i : %@",[ currentDevice classOfDevice ], [ currentDevice name ]);    
        }
    }
    return 0;
}

Thanks for any help of pointers into the right direction.



解决方案:

It looks like you are missing including the IOBluetooth.framework in your project. You can add it by:

-Clicking on your project in the upper left of the left pane (the blue icon).

-In the middle pane, click on the Build Phases tab.

-Under "Link Binary With Libraries", click on the plus button.

-Find the IOBluetooth.framework from the list and hit Add.

enter image description here

enter image description here

This will make sure that the IOBluetooth.framework definitions are found by the linker. You can see that the framework is a member of your target by clicking on the framework in the left pane and seeing the framework's target membership in the right pane (note I've moved the framework under the Frameworks group for organization purposes):

enter image description here


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值