From 0af145ae5789dfbd89c92678fcc075f492c3a0cb Mon Sep 17 00:00:00 2001 From: axgdcode Date: Fri, 8 May 2026 19:12:11 +0200 Subject: [PATCH] Fix build on macOS Apple Silicon (darwin-aarch64) When building libusb4java with a statically linked libusb on macOS, the linker fails with undefined symbols for CoreFoundation, IOKit, Security and objc because libusb itself depends on those Apple frameworks. Add an APPLE-guarded block in src/CMakeLists.txt that links those four system frameworks when building on macOS: if(APPLE) target_link_libraries(usb4java "-framework CoreFoundation" "-framework IOKit" "-framework Security" "-lobjc" ) endif() Without this change the build script (dists/darwin/build) fails at the link step with errors like: Undefined symbols for architecture arm64: _IOCreatePlugInInterfaceForService, referenced from ... _kIOMasterPortDefault, referenced from ... Verified on macOS 15 (Sequoia) / Apple M3 with Temurin JDK 21. Fixes usb4java/libusb4java#12 and closes usb4java/usb4java#86. --- src/CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a739520..e57ec00 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,4 +4,12 @@ target_link_libraries(usb4java ${LibUsb_LIBRARIES}) if(CMAKE_COMPILER_IS_GNUCC) set_target_properties(usb4java PROPERTIES LINK_FLAGS -static-libgcc) endif() +if(APPLE) + target_link_libraries(usb4java + "-framework CoreFoundation" + "-framework IOKit" + "-framework Security" + "-lobjc" + ) +endif() install(TARGETS usb4java DESTINATION lib)