[SOLVED] Undefined symbols for architecture x86_64 when building hidapi



  • I've got a C-project (Qt Creator 2.5.2, Qt 4.8.2, OSX 10.7.5) and am trying to compile others among this file: https://github.com/signal11/hidapi/blob/master/mac/hid.c

    These are the first few lines of compiler-output:

    make: Entering directory '/Users/user/Documents/big_red_button'
    g++ -headerpad_max_install_names -arch x86_64 -Xarch_x86_64 -mmacosx-version min=10.5 -o BigRedButton.app/Contents/MacOS/BigRedButton main.o hidapi-mac.o dream_cheeky.o dream_cheeky_big_red_button.o      
    Undefined symbols for architecture x86_64:
      "_CFGetTypeID", referenced from:
          _get_int_property in hidapi-mac.o
      "_CFNumberGetTypeID", referenced from:
          _get_int_property in hidapi-mac.o
      "_CFNumberGetValue", referenced from:
          _get_int_property in hidapi-mac.o
      "_CFRelease", referenced from:
          _free_hid_device in hidapi-mac.o
          _hid_exit in hidapi-mac.o
          _hid_enumerate in hidapi-mac.o
          _hid_open_path in hidapi-mac.o
      "_CFRunLoopAddSource", referenced from:
          _read_thread in hidapi-mac.o
      "_CFRunLoopGetCurrent", referenced from:
          _init_hid_manager in hidapi-mac.o
          _read_thread in hidapi-mac.o
      "_CFRunLoopGetMain", referenced from:
          _hid_close in hidapi-mac.o
      "_CFRunLoopRunInMode", referenced from:
          _process_pending_events in hidapi-mac.o
          _read_thread in hidapi-mac.o
      "_CFRunLoopSourceCreate", referenced from:
          _read_thread in hidapi-mac.o
    

    What am I doing wrong?



  • This is a linker problem. My guess would be that your -mmacosx-version-min=10.5 is conflicting somehow with your requirement to build with the x86_64 architecture.



  • Oups, sorry... You are missing a link to the CoreFoundation framework!

    LIBS += CoreFoundation


  • Thank you. After adding it to the .pro file I get the error message:

    g++ -headerpad_max_install_names -arch x86_64 -Xarch_x86_64 -mmacosx-version min=10.5 -o BigRedButton.app/Contents/MacOS/BigRedButton main.o hidapi-mac.o dream_cheeky.o dream_cheeky_big_red_button.o     CoreFoundation 
    i686-apple-darwin11-llvm-g++-4.2: CoreFoundation: No such file or directory
    

    XCode and all required frameworks are installed though.



  • I am not a big fan/user of qmake so... Would you try
    LIBS += -framework CoreFoundation ?



  • That one works but I get the same error as in the first post.



  • What version of Mac OS X are you running? Did you remove the minimum compatibility of 10.5?



  • I am on 10.7.4 and don't know how to remove the 10.5 requirement. QtCreator adds it automatically.



  • Could you please paste back the exact error message you have now?



  • I didn't notice that it changed. It is now:

    g++ -headerpad_max_install_names -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -o BigRedButton.app/Contents/MacOS/BigRedButton main.o hidapi-mac.o dream_cheeky.o dream_cheeky_big_red_button.o     -framework CoreFoundation 
    Undefined symbols for architecture x86_64:
      "_IOHIDDeviceClose", referenced from:
    make: Leaving directory `/Users/ali/Documents/big_red_button/BigRedButton'
          _hid_close in hidapi-mac.o
      "_IOHIDDeviceGetProperty", referenced from:
          _get_int_property in hidapi-mac.o
          _get_string_property in hidapi-mac.o
          _get_string_property_utf8 in hidapi-mac.o
      "_IOHIDDeviceGetReport", referenced from:
          _hid_get_feature_report in hidapi-mac.o
      "_IOHIDDeviceOpen", referenced from:
          _hid_open_path in hidapi-mac.o
      "_IOHIDDeviceRegisterInputReportCallback", referenced from:
          _hid_open_path in hidapi-mac.o
          _hid_close in hidapi-mac.o
      "_IOHIDDeviceScheduleWithRunLoop", referenced from:
          _read_thread in hidapi-mac.o
          _hid_close in hidapi-mac.o
      "_IOHIDDeviceSetReport", referenced from:
          _set_report in hidapi-mac.o
      "_IOHIDDeviceUnscheduleFromRunLoop", referenced from:
          _hid_close in hidapi-mac.o
      "_IOHIDManagerClose", referenced from:
          _hid_exit in hidapi-mac.o
      "_IOHIDManagerCopyDevices", referenced from:
          _hid_enumerate in hidapi-mac.o
          _hid_open_path in hidapi-mac.o
      "_IOHIDManagerCreate", referenced from:
          _init_hid_manager in hidapi-mac.o
      "_IOHIDManagerRegisterDeviceRemovalCallback", referenced from:
          _hid_open_path in hidapi-mac.o
          _hid_close in hidapi-mac.o
      "_IOHIDManagerScheduleWithRunLoop", referenced from:
          _init_hid_manager in hidapi-mac.o
      "_IOHIDManagerSetDeviceMatching", referenced from:
          _init_hid_manager in hidapi-mac.o
    ld: symbol(s) not found for architecture x86_64@


  • Alright, so just to give you a hint on how to solve those problems in the future...
    Your missing symbols begin with IOHID. In Mac OS X all classes beginning with IO belong to the "I/O Kit":http://developer.apple.com/library/mac/#documentation/devicedrivers/conceptual/IOKitFundamentals/Introduction/Introduction.html.
    Therefore, you can deduce that you are missing a link to the I/O Kit libraries or "framework".
    Simply add this to your .pro file: LIBS += -framework IOKit



  • Did that ten seconds ago and it finally compiles. Thanks for the help :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.