October 16, 2012

Hedge Hedge
Lab Rat
151 posts

[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:

  1. make: Entering directory `/Users/user/Documents/big_red_button'
  2. 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      
  3. Undefined symbols for architecture x86_64:
  4.  "_CFGetTypeID", referenced from:
  5.      _get_int_property in hidapi-mac.o
  6.  "_CFNumberGetTypeID", referenced from:
  7.      _get_int_property in hidapi-mac.o
  8.  "_CFNumberGetValue", referenced from:
  9.      _get_int_property in hidapi-mac.o
  10.  "_CFRelease", referenced from:
  11.      _free_hid_device in hidapi-mac.o
  12.      _hid_exit in hidapi-mac.o
  13.      _hid_enumerate in hidapi-mac.o
  14.      _hid_open_path in hidapi-mac.o
  15.  "_CFRunLoopAddSource", referenced from:
  16.      _read_thread in hidapi-mac.o
  17.  "_CFRunLoopGetCurrent", referenced from:
  18.      _init_hid_manager in hidapi-mac.o
  19.      _read_thread in hidapi-mac.o
  20.  "_CFRunLoopGetMain", referenced from:
  21.      _hid_close in hidapi-mac.o
  22.  "_CFRunLoopRunInMode", referenced from:
  23.      _process_pending_events in hidapi-mac.o
  24.      _read_thread in hidapi-mac.o
  25.  "_CFRunLoopSourceCreate", referenced from:
  26.      _read_thread in hidapi-mac.o

What am I doing wrong?

11 replies

October 17, 2012

rcari rcari
Lab Rat
161 posts

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.

October 17, 2012

rcari rcari
Lab Rat
161 posts

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

  1. LIBS += CoreFoundation

October 17, 2012

Hedge Hedge
Lab Rat
151 posts

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

  1. 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
  2. i686-apple-darwin11-llvm-g++-4.2: CoreFoundation: No such file or directory

XCode and all required frameworks are installed though.

October 17, 2012

rcari rcari
Lab Rat
161 posts

I am not a big fan/user of qmake so… Would you try

  1. LIBS += -framework CoreFoundation
?

October 17, 2012

Hedge Hedge
Lab Rat
151 posts

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

October 17, 2012

rcari rcari
Lab Rat
161 posts

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

October 17, 2012

Hedge Hedge
Lab Rat
151 posts

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

October 17, 2012

rcari rcari
Lab Rat
161 posts

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

October 18, 2012

Hedge Hedge
Lab Rat
151 posts

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

  1. 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
  2. Undefined symbols for architecture x86_64:
  3.   "_IOHIDDeviceClose", referenced from:
  4. make: Leaving directory `/Users/ali/Documents/big_red_button/BigRedButton'
  5.      _hid_close in hidapi-mac.o
  6.  "_IOHIDDeviceGetProperty", referenced from:
  7.      _get_int_property in hidapi-mac.o
  8.      _get_string_property in hidapi-mac.o
  9.      _get_string_property_utf8 in hidapi-mac.o
  10.  "_IOHIDDeviceGetReport", referenced from:
  11.      _hid_get_feature_report in hidapi-mac.o
  12.  "_IOHIDDeviceOpen", referenced from:
  13.      _hid_open_path in hidapi-mac.o
  14.  "_IOHIDDeviceRegisterInputReportCallback", referenced from:
  15.      _hid_open_path in hidapi-mac.o
  16.      _hid_close in hidapi-mac.o
  17.  "_IOHIDDeviceScheduleWithRunLoop", referenced from:
  18.      _read_thread in hidapi-mac.o
  19.      _hid_close in hidapi-mac.o
  20.  "_IOHIDDeviceSetReport", referenced from:
  21.      _set_report in hidapi-mac.o
  22.  "_IOHIDDeviceUnscheduleFromRunLoop", referenced from:
  23.      _hid_close in hidapi-mac.o
  24.  "_IOHIDManagerClose", referenced from:
  25.      _hid_exit in hidapi-mac.o
  26.  "_IOHIDManagerCopyDevices", referenced from:
  27.      _hid_enumerate in hidapi-mac.o
  28.      _hid_open_path in hidapi-mac.o
  29.  "_IOHIDManagerCreate", referenced from:
  30.      _init_hid_manager in hidapi-mac.o
  31.  "_IOHIDManagerRegisterDeviceRemovalCallback", referenced from:
  32.      _hid_open_path in hidapi-mac.o
  33.      _hid_close in hidapi-mac.o
  34.  "_IOHIDManagerScheduleWithRunLoop", referenced from:
  35.      _init_hid_manager in hidapi-mac.o
  36.  "_IOHIDManagerSetDeviceMatching", referenced from:
  37.      _init_hid_manager in hidapi-mac.o
  38. ld: symbol(s) not found for architecture x86_64

October 18, 2012

rcari rcari
Lab Rat
161 posts

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 [developer.apple.com].
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:

  1. LIBS += -framework IOKit

October 18, 2012

Hedge Hedge
Lab Rat
151 posts

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

 
  ‹‹ [Solved]Need to install any supporting software to execute the .exe file from other systems?      Missing Visual Studio Integration with Qt ››

You must log in to post a reply. Not a member yet? Register here!