Can you provide some more information about your build to help track this down - what deployment target do you have set? And which macOS SDK are you building against? Are you able to reproduce this with a basic JUCE GUI application or are you building a plug-in?
I’ll try to bake a minimal example of this later today, but in the meantime: macOS SDK is 12.0 (as per the command line above), with option macosx-version-min=11.6. In case it’s relevant: I am building a macOS GUI app, not in the standard way but by linking against a static lib that contains JUCE modules:
Without this line, I get the same linker error as above, plus an additional warning:
warning: 'kIOMainPortDefault' is only available on macOS 12.0 or newer [-Wunguarded-availability-new]
note: enclose 'kIOMainPortDefault' in an @available check to silence this warning
Thanks. That was a bit of a long shot as it’s really not clear what’s going wrong here. Something in the newer compiler not finding a symbol in the same set of frameworks? Sorry we can’t be more helpful.
I will try to reproduce it minimally (not today as previously mentioned, but soon hopefully). Could you give me a bit more context as to when this constant is used? What should I use in my minimal example to require access to it?
Hi @t0m, sorry for the late reply, here is a bit more info.
Calling kikoo.mm your test app above, here is are some raw findings:
$CLANG kikoo.mm fails at link time for both $CLANG=/usr/bin/clang++ (Xcode’s latest clang) and $CLANG=/usr/local/Cellar/llvm/13.0.0_2/bin/clang++ (Homebrew’s clang).
Undefined symbols for architecture x86_64:
"_kIOMainPortDefault", referenced from:
_main in kikoo-a29ff3.o
"_kIOMasterPortDefault", referenced from:
_main in kikoo-a29ff3.o
ld: symbol(s) not found for architecture x86_64
That’s expected I guess. Adding -framework IOKit to the command lines above solves the issue in both cases (linking succeeds).
Now compiling through this simple CMakeLists.txt :
Now when Homebrew’s clang is selected, linking fails as above. The command line is exactly the same, except for the executable path obviously (/usr/local/Cellar/llvm/13.0.0_2/bin/clang++).
I realize this is quite a raw lot of info, and probably beyond the scope of JUCE per se…
Can you reproduce this at all?
I tried using CMake 3.22.1 and Homebrew clang version 13.0.0 on both an macOS 12.1 ARM and x86_64 Mac, using the Makefiles exporter and VERBOSE=1 make.
JUCE develop branch tip.
cmake_minimum_required(VERSION 3.15)
project(kikoo VERSION 1.0.0 LANGUAGES C CXX)
add_subdirectory(JUCE)
juce_add_gui_app(kikoo)
target_sources(kikoo PRIVATE kikoo.mm)
target_link_libraries(kikoo
PRIVATE
juce::juce_gui_extra
juce::juce_recommended_lto_flags
juce::juce_recommended_warning_flags
juce::juce_recommended_config_flags
)