0

我想在 Xcode 4 中构建 HID Explorer 示例,但是当我尝试构建时,出现以下错误(无论是 32 还是 64):

Undefined symbols for architecture x86_64:
  "_DisposeMenu", referenced from:
      _Handle_WindowEvents in main.o
  "_GetControl32BitMaximum", referenced from:
      _Handle_EventControlDraw in main.o
  "_GetControl32BitMinimum", referenced from:
      _Handle_EventControlDraw in main.o
  "_GetControl32BitValue", referenced from:
      _Handle_EventControlDraw in main.o
  "_InvalWindowRect", referenced from:
      _SetElementTitle in main.o
  "_SetControl32BitMaximum", referenced from:
      _Update_WindowElementInfo in main.o
  "_SetControl32BitMinimum", referenced from:
      _Update_WindowElementInfo in main.o
  "_SetControl32BitValue", referenced from:
      _DisplayCurrentDeviceElementValue in main.o
  "_SetControlMaximum", referenced from:
      _Build_DeviceMenu in main.o
      _Build_ElementMenu 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)

我假设,缺少一个框架。谁能告诉我,是哪一个?

已经包含的框架有:CoreFoundation.framework、IOKit.framework、Carbon.framework

4

2 回答 2

0

HID Explorer 是一个 Legacy Carbon 示例,它使用 IOKit 与 HID 设备通信。您应该考虑改用 10.5 中引入的 HID 管理器。请参阅:https ://developer.apple.com/library/mac/#documentation/DeviceDrivers/Conceptual/HID/intro/intro.html 。

下面是一些使用 HID 管理器迭代所有连接的 HID 设备的最小代码:

int main(int argc, const char * argv[]) 
{
    IOHIDManagerRef tIOHIDManagerRef = NULL;
    CFSetRef deviceCFSetRef = NULL;
    IOHIDDeviceRef *tIOHIDDeviceRefs = nil;

    do {    // psudo try/throw block
        tIOHIDManagerRef = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
        if (!tIOHIDManagerRef) break;

        IOHIDManagerSetDeviceMatching(tIOHIDManagerRef, NULL);

        IOReturn tIOReturn = IOHIDManagerOpen(tIOHIDManagerRef, kIOHIDOptionsTypeNone);
        if (noErr != tIOReturn) break;

        deviceCFSetRef = IOHIDManagerCopyDevices(tIOHIDManagerRef);
        if (!deviceCFSetRef) break;

        CFIndex deviceIndex, deviceCount = CFSetGetCount(deviceCFSetRef);

        tIOHIDDeviceRefs = malloc(sizeof(IOHIDDeviceRef) * deviceCount);
        if (!tIOHIDDeviceRefs) break;

        CFSetGetValues(deviceCFSetRef, (const void **)tIOHIDDeviceRefs);
        CFRelease(deviceCFSetRef);
        deviceCFSetRef = NULL;
        for (deviceIndex = 0; deviceIndex < deviceCount; deviceIndex++) {
            if (!tIOHIDDeviceRefs[deviceIndex]) continue;

            // dump the HID device info 
            // HIDDumpDeviceInfo(tIOHIDDeviceRefs[deviceIndex]);
        }
    } while (false);

    if (tIOHIDDeviceRefs) {
        free(tIOHIDDeviceRefs);
    }
    if (deviceCFSetRef) {
        CFRelease(deviceCFSetRef);
        deviceCFSetRef = NULL;
    }
    if (tIOHIDManagerRef) {
        CFRelease(tIOHIDManagerRef);
    }

    return (0);
} // main
于 2013-05-01T20:12:32.907 回答
0

除非您想重写代码本身,否则唯一有效的架构是(ppc 和 i386)。当我尝试构建包含x86_64的项目时,我重现了确切的错误。当我删除该架构时,项目构建并运行得很好。

有效架构:ppc i386或只是i386

有效的拱门

于 2013-05-01T01:41:43.973 回答