ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
60.72k stars 10.26k forks source link

Undefined symbol "_OBJC_CLASS_$_GCController" error on Mac #5938

Closed TheMostDiligent closed 1 year ago

TheMostDiligent commented 1 year ago

Version/Branch of Dear ImGui:

Version: 1.89.1 Branch: master

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_osx.mm + custom Compiler: AppleClang 13.1.6.13160021 (XCode 13.4) Operating System: MacOS (M1, arm64)

My Issue/Question:

After updating to the latest version (my was ~3 years old), I started getting the following linking errors when building on MacOS:

Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_GCController", referenced from:
      objc-class-ref in libDiligent-Imgui.a(imgui_impl_osx.o)
ld: symbol(s) not found for architecture arm64

There seems to be nothing special about how imgui_impl_osx.mm is being built compared to other objective-c++ files, and I ran out of ideas of what may be wrong. Googling "_OBJCCLASS$_GCController" gives exactly zero relevant results. I tried:

Any suggestion would be highly appreciated. Thank you!

TheMostDiligent commented 1 year ago

OK, after comparing the example XCode project settings line-by-line I finally found that Mac implementation now requires the GameController framework. Linking with it fixed the problem. It may be worth adding a note in imgui_impl_osx.mm that this framework is now a requirement.

ocornut commented 1 year ago

Thank you, will add comments in an incoming commit.