MacOS testgui make error #151

Closed
opened 2020-03-02 12:14:21 -06:00 by 84Park · 26 comments
84Park commented 2020-03-02 12:14:21 -06:00 (Migrated from github.com)

Hardware: MacBook Pro, MacOS 10.15
Software: fox-toolkit installed with MacPorts
("./configure && make && make install" of fox toolkit on Mac fails with several files not found)

testgui % gmake -f Makefile-manual

g++ -I../hidapi -Wall -g -c fox-config --cflags test.cpp -o test.o
g++ -I../hidapi -Wall -g -c fox-config --cflags -x objective-c++ mac_support_cocoa.m -o mac_support_cocoa.o
rm -Rf TestGUI.app
mkdir -p TestGUI.app
cp -R TestGUI.app.in/ TestGUI.app
g++ -Wall -g ../mac/hid.o test.o mac_support_cocoa.o fox-config --libs -framework IOKit -framework CoreFoundation -framework Cocoa -L/usr/X11R6/lib -o hidapi-testgui
ld: warning: directory not found for option '-L/usr/X11R6/lib'
./copy_to_bundle.sh
application/x-mach-binary; charset=binary
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump:
error: '/Users/xxx/Documents/Arduino/hidapi/testgui/TestGUI.app/Contents/MacOS/hidapi-testgui': Not a directory
#cp TestGUI.app/Contents/MacOS/hidapi-testgui TestGUI.app/Contents/MacOS/tg
#cp start.sh TestGUI.app/Contents/MacOS/hidapi-testgui

Hardware: MacBook Pro, MacOS 10.15 Software: fox-toolkit installed with MacPorts ("./configure && make && make install" of fox toolkit on Mac fails with several files not found) testgui % **gmake -f Makefile-manual** g++ -I../hidapi -Wall -g -c `fox-config --cflags` test.cpp -o test.o g++ -I../hidapi -Wall -g -c `fox-config --cflags` -x objective-c++ mac_support_cocoa.m -o mac_support_cocoa.o rm -Rf TestGUI.app mkdir -p TestGUI.app cp -R TestGUI.app.in/ TestGUI.app g++ -Wall -g ../mac/hid.o test.o mac_support_cocoa.o `fox-config --libs` -framework IOKit -framework CoreFoundation -framework Cocoa -L/usr/X11R6/lib -o hidapi-testgui **ld: warning: directory not found for option '-L/usr/X11R6/lib'** ./copy_to_bundle.sh application/x-mach-binary; charset=binary /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump: **error: '/Users/xxx/Documents/Arduino/hidapi/testgui/TestGUI.app/Contents/MacOS/hidapi-testgui': Not a directory** #cp TestGUI.app/Contents/MacOS/hidapi-testgui TestGUI.app/Contents/MacOS/tg #cp start.sh TestGUI.app/Contents/MacOS/hidapi-testgui
84Park commented 2020-03-02 12:52:01 -06:00 (Migrated from github.com)

The unix executable file that is built, "hidapi-testgui", does run by double click on file in Finder or by using terminal command line "./hidapi-testgui"

hidapi-testgui will find and open a device and send and receive reports.

The unix executable file that is built, "hidapi-testgui", does run by double click on file in Finder or by using terminal command line "./hidapi-testgui" hidapi-testgui will find and open a device and send and receive reports.
Youw commented 2020-03-02 20:39:28 -06:00 (Migrated from github.com)

I think you're the first user of this GUI app for a long time (on macOS)

Can't promise me or anyone from the team is going to check on it any time soon

Feel free to try fixing it yourself and opening a PR - help is welcome

I think you're the first user of this GUI app for a long time (on macOS) Can't promise me or anyone from the team is going to check on it any time soon Feel free to try fixing it yourself and opening a PR - help is welcome
z3ntu commented 2020-03-05 06:58:12 -06:00 (Migrated from github.com)

image
Works fine for me with the autotools build process (fox is installed via homebrew as far as I can tell)

But it looks like the manual Makefile is indeed broken

![image](https://user-images.githubusercontent.com/3768500/75983550-0905fe00-5ee9-11ea-8a25-8681b8d52260.png) Works fine for me with the autotools build process (`fox` is installed via homebrew as far as I can tell) But it looks like the manual Makefile is indeed broken
Youw commented 2020-03-05 08:09:57 -06:00 (Migrated from github.com)

thanks @z3ntu, that's awesome you've checked it

we're ready to merge #152

@84Park would you care to check is it fixes the issue in your environment?

thanks @z3ntu, that's awesome you've checked it we're ready to merge #152 @84Park would you care to check is it fixes the issue in your environment?
84Park commented 2020-03-08 10:28:31 -05:00 (Migrated from github.com)

Thank you. I modified copy_to_bundle.sh with "mkdir -p $EXEPATH" and that removed the error reported in #151 (error: '/Users/xxx/Documents/Arduino/hidapi/testgui/TestGUI.app/Contents/MacOS/hidapi-testgui': Not a directory)

Good job!

Thank you. I modified copy_to_bundle.sh with "mkdir -p $EXEPATH" and that removed the error reported in #151 (error: '/Users/xxx/Documents/Arduino/hidapi/testgui/TestGUI.app/Contents/MacOS/hidapi-testgui': Not a directory) Good job!
mcuee commented 2021-08-28 07:17:27 -05:00 (Migrated from github.com)

https://github.com/mcuee/hidapi/releases
Here is a x64 binary snapshot tested under my Mac Mini M1 (with Rosetta 2). I am not so sure how to build the native ARM64 binary as the bundle seems to be a bit off.

https://github.com/mcuee/hidapi/releases Here is a x64 binary snapshot tested under my Mac Mini M1 (with Rosetta 2). I am not so sure how to build the native ARM64 binary as the bundle seems to be a bit off.
todbot commented 2021-08-28 14:36:17 -05:00 (Migrated from github.com)

The way I've been building for M1 (arm64) is to build a "fat binary" that contains both executables. It's pretty easy by passing in two -arch flags to CFLAGS. Here's how hidapitester does it:
github.com/todbot/hidapitester@eb8bae29a4

The result is checkable with file:

% file hidapitester
hidapitester: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64:Mach-O 64-bit executable arm64]
hidapitester (for architecture x86_64):	Mach-O 64-bit executable x86_64
hidapitester (for architecture arm64):	Mach-O 64-bit executable arm64

(This was just added. I'm using this technique on a few other projects with success. I clearly need to fix the hidapitester CI now :-)

The way I've been building for M1 (arm64) is to build a "fat binary" that contains both executables. It's pretty easy by passing in two `-arch` flags to CFLAGS. Here's how `hidapitester` does it: https://github.com/todbot/hidapitester/commit/eb8bae29a44e2f38563df6164f0019e868d6fa3a The result is checkable with `file`: ```sh % file hidapitester hidapitester: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64:Mach-O 64-bit executable arm64] hidapitester (for architecture x86_64): Mach-O 64-bit executable x86_64 hidapitester (for architecture arm64): Mach-O 64-bit executable arm64 ``` (This was just added. I'm using this technique on a few other projects with success. I clearly need to fix the hidapitester CI now :-)
mcuee commented 2021-08-28 20:40:51 -05:00 (Migrated from github.com)

Nice tip. But I do not know how to apply the same tip to GUI applications which relies on multiple libraries.

I am using Homebrew and the auto-tools to build test-gui (it is not suppored by CMake). The issue is in the bundling portion that it does not know to bundle the right ARM64 version (/opt/homebrew/lib) of libjpeg.dylib and libtiff.dylib.

As a result, the GUI application hidapitest-gui is working, but not the TestGUI.app bundle.

hidapi/build_autotool on  master [?] ❯ make
/Library/Developer/CommandLineTools/usr/bin/make  all-recursive
Making all in mac
  CC       hid.lo
  CCLD     libhidapi.la
Making all in hidtest
  CC       test.o
  CCLD     hidtest
Making all in testgui
  CXX      test.o
  OBJC     mac_support_cocoa.o
  CXXLD    hidapi-testgui
ld: warning: ignoring file /usr/local/lib/libjpeg.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file /usr/local/lib/libtiff.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
../../testgui/copy_to_bundle.sh
libtool: warning: '../mac/libhidapi.la' has not been installed in '/usr/local/lib'
libtool: install: cp .libs/hidapi-testgui /Users/mcuee/build/hidapi/hidapi/build_autotool/testgui/TestGUI.app/Contents/MacOS/hidapi-testgui
bundling /opt/homebrew/opt/fox/lib/libFOX-1.6.0.dylib because it's in the list.
/Library/Developer/CommandLineTools/usr/bin/install_name_tool: warning: changes being made to the file will invalidate the code signature in: /Users/mcuee/build/hidapi/hidapi/build_autotool/testgui/TestGUI.app/Contents/MacOS/libFOX-1.6.0.dylib
bundling @executable_path/libFOX-1.6.0.dylib because it's in the list.
make[2]: Nothing to be done for `all-am'.
Nice tip. But I do not know how to apply the same tip to GUI applications which relies on multiple libraries. I am using Homebrew and the auto-tools to build test-gui (it is not suppored by CMake). The issue is in the bundling portion that it does not know to bundle the right ARM64 version (/opt/homebrew/lib) of libjpeg.dylib and libtiff.dylib. As a result, the GUI application hidapitest-gui is working, but not the TestGUI.app bundle. ``` hidapi/build_autotool on  master [?] ❯ make /Library/Developer/CommandLineTools/usr/bin/make all-recursive Making all in mac CC hid.lo CCLD libhidapi.la Making all in hidtest CC test.o CCLD hidtest Making all in testgui CXX test.o OBJC mac_support_cocoa.o CXXLD hidapi-testgui ld: warning: ignoring file /usr/local/lib/libjpeg.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64 ld: warning: ignoring file /usr/local/lib/libtiff.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64 ../../testgui/copy_to_bundle.sh libtool: warning: '../mac/libhidapi.la' has not been installed in '/usr/local/lib' libtool: install: cp .libs/hidapi-testgui /Users/mcuee/build/hidapi/hidapi/build_autotool/testgui/TestGUI.app/Contents/MacOS/hidapi-testgui bundling /opt/homebrew/opt/fox/lib/libFOX-1.6.0.dylib because it's in the list. /Library/Developer/CommandLineTools/usr/bin/install_name_tool: warning: changes being made to the file will invalidate the code signature in: /Users/mcuee/build/hidapi/hidapi/build_autotool/testgui/TestGUI.app/Contents/MacOS/libFOX-1.6.0.dylib bundling @executable_path/libFOX-1.6.0.dylib because it's in the list. make[2]: Nothing to be done for `all-am'. ```
mcuee commented 2021-08-28 20:54:17 -05:00 (Migrated from github.com)

Even if I copy the necessary dylib files to the TestGUI.app/Contents/MacOS folder to be in the same directory with hidapi-testgui, TestGui.app will still crash as it still wants to find /usr/local/lib files which are of x64 arch.

Process:               hidapi-testgui [2795]
Path:                  /Users/USER/*/TestGUI.app/Contents/MacOS/hidapi-testgui
Identifier:            us.signal11.hidtestgui
Version:               1.0
Code Type:             ARM-64 (Native)
Parent Process:        ??? [1]
Responsible:           hidapi-testgui [2795]
User ID:               501

Date/Time:             2021-08-29 09:51:08.947 +0800
OS Version:            macOS 11.5.2 (20G95)
Report Version:        12
Anonymous UUID:        42E4176B-6AC7-D4CA-E9DC-A4B9DEA90EE3


Time Awake Since Boot: 1300 seconds

System Integrity Protection: enabled

Crashed Thread:        0

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    DYLD, [0x2] Wrong architecture

Application Specific Information:
dyld: launch, loading dependent libraries

Dyld Error Message:
  Library not loaded: /usr/local/lib/libhidapi.0.dylib
  Referenced from: /Users/USER/*/TestGUI.app/Contents/MacOS/hidapi-testgui
  Reason: no suitable image found.  Did find:
	/usr/local/lib/libhidapi.0.dylib: mach-o, but wrong architecture
	/usr/local/lib/libhidapi.0.dylib: stat() failed with errno=1
	/usr/local/lib/libhidapi.0.dylib: mach-o, but wrong architecture
	/usr/local/Cellar/hidapi/HEAD-4d63a50/lib/libhidapi.0.dylib: mach-o, but wrong architecture
	/usr/local/Cellar/hidapi/HEAD-4d63a50/lib/libhidapi.0.dylib: mach-o, but wrong architecture
...


Even if I copy the necessary dylib files to the TestGUI.app/Contents/MacOS folder to be in the same directory with hidapi-testgui, TestGui.app will still crash as it still wants to find /usr/local/lib files which are of x64 arch. ``` Process: hidapi-testgui [2795] Path: /Users/USER/*/TestGUI.app/Contents/MacOS/hidapi-testgui Identifier: us.signal11.hidtestgui Version: 1.0 Code Type: ARM-64 (Native) Parent Process: ??? [1] Responsible: hidapi-testgui [2795] User ID: 501 Date/Time: 2021-08-29 09:51:08.947 +0800 OS Version: macOS 11.5.2 (20G95) Report Version: 12 Anonymous UUID: 42E4176B-6AC7-D4CA-E9DC-A4B9DEA90EE3 Time Awake Since Boot: 1300 seconds System Integrity Protection: enabled Crashed Thread: 0 Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Termination Reason: DYLD, [0x2] Wrong architecture Application Specific Information: dyld: launch, loading dependent libraries Dyld Error Message: Library not loaded: /usr/local/lib/libhidapi.0.dylib Referenced from: /Users/USER/*/TestGUI.app/Contents/MacOS/hidapi-testgui Reason: no suitable image found. Did find: /usr/local/lib/libhidapi.0.dylib: mach-o, but wrong architecture /usr/local/lib/libhidapi.0.dylib: stat() failed with errno=1 /usr/local/lib/libhidapi.0.dylib: mach-o, but wrong architecture /usr/local/Cellar/hidapi/HEAD-4d63a50/lib/libhidapi.0.dylib: mach-o, but wrong architecture /usr/local/Cellar/hidapi/HEAD-4d63a50/lib/libhidapi.0.dylib: mach-o, but wrong architecture ... ```
mcuee commented 2021-08-28 21:00:11 -05:00 (Migrated from github.com)

So my question is how to specify the dylib directory. In the command line, I can do that. But I do not know how to do that in the app bundle.

TestGUI.app/Contents/MacOS on  master [?] ❯ ./hidapi-testgui 
dyld: Library not loaded: /usr/local/lib/libhidapi.0.dylib
  Referenced from: /Users/mcuee/build/hidapi/hidapi/build_autotool/testgui/TestGUI.app/Contents/MacOS/./hidapi-testgui
  Reason: no suitable image found.  Did find:
	/usr/local/lib/libhidapi.0.dylib: mach-o, but wrong architecture
	/usr/local/lib/libhidapi.0.dylib: stat() failed with errno=1
	/usr/local/lib/libhidapi.0.dylib: mach-o, but wrong architecture
	/usr/local/Cellar/hidapi/HEAD-4d63a50/lib/libhidapi.0.dylib: mach-o, but wrong architecture
	/usr/local/Cellar/hidapi/HEAD-4d63a50/lib/libhidapi.0.dylib: mach-o, but wrong architecture
zsh: abort      ./hidapi-testgui

TestGUI.app/Contents/MacOS on  master [?] ❯ DYLD_LIBRARY_PATH=/opt/homebrew/lib ./hidapi-testgui     
Unable to revert mtime: /Library/Fonts
So my question is how to specify the dylib directory. In the command line, I can do that. But I do not know how to do that in the app bundle. ``` TestGUI.app/Contents/MacOS on  master [?] ❯ ./hidapi-testgui dyld: Library not loaded: /usr/local/lib/libhidapi.0.dylib Referenced from: /Users/mcuee/build/hidapi/hidapi/build_autotool/testgui/TestGUI.app/Contents/MacOS/./hidapi-testgui Reason: no suitable image found. Did find: /usr/local/lib/libhidapi.0.dylib: mach-o, but wrong architecture /usr/local/lib/libhidapi.0.dylib: stat() failed with errno=1 /usr/local/lib/libhidapi.0.dylib: mach-o, but wrong architecture /usr/local/Cellar/hidapi/HEAD-4d63a50/lib/libhidapi.0.dylib: mach-o, but wrong architecture /usr/local/Cellar/hidapi/HEAD-4d63a50/lib/libhidapi.0.dylib: mach-o, but wrong architecture zsh: abort ./hidapi-testgui TestGUI.app/Contents/MacOS on  master [?] ❯ DYLD_LIBRARY_PATH=/opt/homebrew/lib ./hidapi-testgui Unable to revert mtime: /Library/Fonts ```
mcuee commented 2021-08-28 21:17:53 -05:00 (Migrated from github.com)

Full build-log for ARM64. "/Users/mcuee/bin/bin/hidapi-testgui" works just fine. But the "TestGUI.app" is not working.


hidapi/build_autotool on  master [?] ❯ ../configure --enable-testgui --prefix=/Users/mcuee/bin 
checking for a BSD-compatible install... /opt/homebrew/bin/ginstall -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... /opt/homebrew/bin/gmkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports the include directive... yes (GNU style)
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for ar... ar
checking the archiver (ar) interface... ar
checking build system type... aarch64-apple-darwin20.6.0
checking host system type... aarch64-apple-darwin20.6.0
checking how to print strings... printf
checking for a sed that does not truncate output... /opt/homebrew/bin/gsed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /Library/Developer/CommandLineTools/usr/bin/ld
checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 786432
checking how to convert aarch64-apple-darwin20.6.0 file names to aarch64-apple-darwin20.6.0 format... func_convert_file_noop
checking how to convert aarch64-apple-darwin20.6.0 file names to toolchain format... func_convert_file_noop
checking for /Library/Developer/CommandLineTools/usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @FILE support... no
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for lipo... lipo
checking for otool... otool
checking for otool64... no
checking for -single_module linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking for -force_load linker flag... yes
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... yes
checking for gcc option to produce PIC... -fno-common -DPIC
checking if gcc PIC flag -fno-common -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin20.6.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for gcc... (cached) gcc
checking whether the compiler supports GNU C... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to enable C11 features... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking dependency style of gcc... (cached) gcc3
checking for g++... g++
checking whether the compiler supports GNU C++... yes
checking whether g++ accepts -g... yes
checking for g++ option to enable C++11 features... none needed
checking dependency style of g++... gcc3
checking how to run the C++ preprocessor... g++ -E
checking for ld used by g++... /Library/Developer/CommandLineTools/usr/bin/ld
checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no
checking whether the g++ linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes
checking for g++ option to produce PIC... -fno-common -DPIC
checking if g++ PIC flag -fno-common -DPIC works... yes
checking if g++ static flag -static works... no
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin20.6.0 dyld
checking how to hardcode library paths into programs... immediate
checking for gcc... gcc
checking whether the compiler supports GNU Objective C... yes
checking whether gcc accepts -g... yes
checking dependency style of gcc... gcc3
checking for pkg-config... /opt/homebrew/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking whether make supports nested variables... (cached) yes
checking operating system... aarch64-apple-darwin20.6.0
 (Mac OS X back-end)
checking whether pthreads work with -pthread... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking if more special flags are required for pthreads... -D_THREAD_SAFE
checking for PTHREAD_PRIO_INHERIT... yes
checking for fox-config... fox-config
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating pc/hidapi.pc
config.status: creating Makefile
config.status: creating hidtest/Makefile
config.status: creating libusb/Makefile
config.status: creating linux/Makefile
config.status: creating mac/Makefile
config.status: creating testgui/Makefile
config.status: creating windows/Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
hidapi/build_autotool on  master [?] took 3s ❯ make
/Library/Developer/CommandLineTools/usr/bin/make  all-recursive
Making all in mac
  CC       hid.lo
  CCLD     libhidapi.la
Making all in hidtest
  CC       test.o
  CCLD     hidtest
Making all in testgui
  CXX      test.o
  OBJC     mac_support_cocoa.o
  CXXLD    hidapi-testgui
ld: warning: ignoring file /usr/local/lib/libjpeg.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file /usr/local/lib/libtiff.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
../../testgui/copy_to_bundle.sh
libtool: install: cp .libs/hidapi-testgui /Users/mcuee/build/hidapi/hidapi/build_autotool/testgui/TestGUI.app/Contents/MacOS/hidapi-testgui
bundling /opt/homebrew/opt/fox/lib/libFOX-1.6.0.dylib because it's in the list.
/Library/Developer/CommandLineTools/usr/bin/install_name_tool: warning: changes being made to the file will invalidate the code signature in: /Users/mcuee/build/hidapi/hidapi/build_autotool/testgui/TestGUI.app/Contents/MacOS/libFOX-1.6.0.dylib
bundling @executable_path/libFOX-1.6.0.dylib because it's in the list.
make[2]: Nothing to be done for `all-am'.
hidapi/build_autotool on  master [?] ❯ make install
Making install in mac
 /opt/homebrew/bin/gmkdir -p '/Users/mcuee/bin/lib'
 /bin/sh ../libtool   --mode=install /opt/homebrew/bin/ginstall -c   libhidapi.la '/Users/mcuee/bin/lib'
libtool: install: /opt/homebrew/bin/ginstall -c .libs/libhidapi.0.dylib /Users/mcuee/bin/lib/libhidapi.0.dylib
libtool: install: (cd /Users/mcuee/bin/lib && { ln -s -f libhidapi.0.dylib libhidapi.dylib || { rm -f libhidapi.dylib && ln -s libhidapi.0.dylib libhidapi.dylib; }; })
libtool: install: /opt/homebrew/bin/ginstall -c .libs/libhidapi.lai /Users/mcuee/bin/lib/libhidapi.la
libtool: install: /opt/homebrew/bin/ginstall -c .libs/libhidapi.a /Users/mcuee/bin/lib/libhidapi.a
libtool: install: chmod 644 /Users/mcuee/bin/lib/libhidapi.a
libtool: install: ranlib /Users/mcuee/bin/lib/libhidapi.a
 /opt/homebrew/bin/gmkdir -p '/Users/mcuee/bin/include/hidapi'
 /opt/homebrew/bin/ginstall -c -m 644 ../../hidapi/hidapi.h '/Users/mcuee/bin/include/hidapi'
Making install in hidtest
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
Making install in testgui
 /opt/homebrew/bin/gmkdir -p '/Users/mcuee/bin/bin'
  /bin/sh ../libtool   --mode=install /opt/homebrew/bin/ginstall -c hidapi-testgui '/Users/mcuee/bin/bin'
libtool: install: /opt/homebrew/bin/ginstall -c .libs/hidapi-testgui /Users/mcuee/bin/bin/hidapi-testgui
make[2]: Nothing to be done for `install-data-am'.
make[2]: Nothing to be done for `install-exec-am'.
 /opt/homebrew/bin/gmkdir -p '/Users/mcuee/bin/share/doc/hidapi'
 /opt/homebrew/bin/ginstall -c -m 644 ../README.md ../AUTHORS.txt ../LICENSE-bsd.txt ../LICENSE-gpl3.txt ../LICENSE-orig.txt ../LICENSE.txt '/Users/mcuee/bin/share/doc/hidapi'
 /opt/homebrew/bin/gmkdir -p '/Users/mcuee/bin/lib/pkgconfig'
 /opt/homebrew/bin/ginstall -c -m 644 pc/hidapi.pc '/Users/mcuee/bin/lib/pkgconfig'
Full build-log for ARM64. "/Users/mcuee/bin/bin/hidapi-testgui" works just fine. But the "TestGUI.app" is not working. ``` hidapi/build_autotool on  master [?] ❯ ../configure --enable-testgui --prefix=/Users/mcuee/bin checking for a BSD-compatible install... /opt/homebrew/bin/ginstall -c checking whether build environment is sane... yes checking for a race-free mkdir -p... /opt/homebrew/bin/gmkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking whether make supports the include directive... yes (GNU style) checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether the compiler supports GNU C... yes checking whether gcc accepts -g... yes checking for gcc option to enable C11 features... none needed checking whether gcc understands -c and -o together... yes checking dependency style of gcc... gcc3 checking for ar... ar checking the archiver (ar) interface... ar checking build system type... aarch64-apple-darwin20.6.0 checking host system type... aarch64-apple-darwin20.6.0 checking how to print strings... printf checking for a sed that does not truncate output... /opt/homebrew/bin/gsed checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for fgrep... /usr/bin/grep -F checking for ld used by gcc... /Library/Developer/CommandLineTools/usr/bin/ld checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B checking the name lister (/usr/bin/nm -B) interface... BSD nm checking whether ln -s works... yes checking the maximum length of command line arguments... 786432 checking how to convert aarch64-apple-darwin20.6.0 file names to aarch64-apple-darwin20.6.0 format... func_convert_file_noop checking how to convert aarch64-apple-darwin20.6.0 file names to toolchain format... func_convert_file_noop checking for /Library/Developer/CommandLineTools/usr/bin/ld option to reload object files... -r checking for objdump... objdump checking how to recognize dependent libraries... pass_all checking for dlltool... no checking how to associate runtime and link libraries... printf %s\n checking for archiver @FILE support... no checking for strip... strip checking for ranlib... ranlib checking command to parse /usr/bin/nm -B output from gcc object... ok checking for sysroot... no checking for a working dd... /bin/dd checking how to truncate binary pipes... /bin/dd bs=4096 count=1 checking for mt... no checking if : is a manifest tool... no checking for dsymutil... dsymutil checking for nmedit... nmedit checking for lipo... lipo checking for otool... otool checking for otool64... no checking for -single_module linker flag... yes checking for -exported_symbols_list linker flag... yes checking for -force_load linker flag... yes checking for stdio.h... yes checking for stdlib.h... yes checking for string.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for strings.h... yes checking for sys/stat.h... yes checking for sys/types.h... yes checking for unistd.h... yes checking for dlfcn.h... yes checking for objdir... .libs checking if gcc supports -fno-rtti -fno-exceptions... yes checking for gcc option to produce PIC... -fno-common -DPIC checking if gcc PIC flag -fno-common -DPIC works... yes checking if gcc static flag -static works... no checking if gcc supports -c -o file.o... yes checking if gcc supports -c -o file.o... (cached) yes checking whether the gcc linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes checking dynamic linker characteristics... darwin20.6.0 dyld checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... yes checking for gcc... (cached) gcc checking whether the compiler supports GNU C... (cached) yes checking whether gcc accepts -g... (cached) yes checking for gcc option to enable C11 features... (cached) none needed checking whether gcc understands -c and -o together... (cached) yes checking dependency style of gcc... (cached) gcc3 checking for g++... g++ checking whether the compiler supports GNU C++... yes checking whether g++ accepts -g... yes checking for g++ option to enable C++11 features... none needed checking dependency style of g++... gcc3 checking how to run the C++ preprocessor... g++ -E checking for ld used by g++... /Library/Developer/CommandLineTools/usr/bin/ld checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no checking whether the g++ linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes checking for g++ option to produce PIC... -fno-common -DPIC checking if g++ PIC flag -fno-common -DPIC works... yes checking if g++ static flag -static works... no checking if g++ supports -c -o file.o... yes checking if g++ supports -c -o file.o... (cached) yes checking whether the g++ linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes checking dynamic linker characteristics... darwin20.6.0 dyld checking how to hardcode library paths into programs... immediate checking for gcc... gcc checking whether the compiler supports GNU Objective C... yes checking whether gcc accepts -g... yes checking dependency style of gcc... gcc3 checking for pkg-config... /opt/homebrew/bin/pkg-config checking pkg-config is at least version 0.9.0... yes checking whether make supports nested variables... (cached) yes checking operating system... aarch64-apple-darwin20.6.0 (Mac OS X back-end) checking whether pthreads work with -pthread... yes checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE checking if more special flags are required for pthreads... -D_THREAD_SAFE checking for PTHREAD_PRIO_INHERIT... yes checking for fox-config... fox-config checking that generated files are newer than configure... done configure: creating ./config.status config.status: creating pc/hidapi.pc config.status: creating Makefile config.status: creating hidtest/Makefile config.status: creating libusb/Makefile config.status: creating linux/Makefile config.status: creating mac/Makefile config.status: creating testgui/Makefile config.status: creating windows/Makefile config.status: creating config.h config.status: executing depfiles commands config.status: executing libtool commands hidapi/build_autotool on  master [?] took 3s ❯ make /Library/Developer/CommandLineTools/usr/bin/make all-recursive Making all in mac CC hid.lo CCLD libhidapi.la Making all in hidtest CC test.o CCLD hidtest Making all in testgui CXX test.o OBJC mac_support_cocoa.o CXXLD hidapi-testgui ld: warning: ignoring file /usr/local/lib/libjpeg.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64 ld: warning: ignoring file /usr/local/lib/libtiff.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64 ../../testgui/copy_to_bundle.sh libtool: install: cp .libs/hidapi-testgui /Users/mcuee/build/hidapi/hidapi/build_autotool/testgui/TestGUI.app/Contents/MacOS/hidapi-testgui bundling /opt/homebrew/opt/fox/lib/libFOX-1.6.0.dylib because it's in the list. /Library/Developer/CommandLineTools/usr/bin/install_name_tool: warning: changes being made to the file will invalidate the code signature in: /Users/mcuee/build/hidapi/hidapi/build_autotool/testgui/TestGUI.app/Contents/MacOS/libFOX-1.6.0.dylib bundling @executable_path/libFOX-1.6.0.dylib because it's in the list. make[2]: Nothing to be done for `all-am'. hidapi/build_autotool on  master [?] ❯ make install Making install in mac /opt/homebrew/bin/gmkdir -p '/Users/mcuee/bin/lib' /bin/sh ../libtool --mode=install /opt/homebrew/bin/ginstall -c libhidapi.la '/Users/mcuee/bin/lib' libtool: install: /opt/homebrew/bin/ginstall -c .libs/libhidapi.0.dylib /Users/mcuee/bin/lib/libhidapi.0.dylib libtool: install: (cd /Users/mcuee/bin/lib && { ln -s -f libhidapi.0.dylib libhidapi.dylib || { rm -f libhidapi.dylib && ln -s libhidapi.0.dylib libhidapi.dylib; }; }) libtool: install: /opt/homebrew/bin/ginstall -c .libs/libhidapi.lai /Users/mcuee/bin/lib/libhidapi.la libtool: install: /opt/homebrew/bin/ginstall -c .libs/libhidapi.a /Users/mcuee/bin/lib/libhidapi.a libtool: install: chmod 644 /Users/mcuee/bin/lib/libhidapi.a libtool: install: ranlib /Users/mcuee/bin/lib/libhidapi.a /opt/homebrew/bin/gmkdir -p '/Users/mcuee/bin/include/hidapi' /opt/homebrew/bin/ginstall -c -m 644 ../../hidapi/hidapi.h '/Users/mcuee/bin/include/hidapi' Making install in hidtest make[2]: Nothing to be done for `install-exec-am'. make[2]: Nothing to be done for `install-data-am'. Making install in testgui /opt/homebrew/bin/gmkdir -p '/Users/mcuee/bin/bin' /bin/sh ../libtool --mode=install /opt/homebrew/bin/ginstall -c hidapi-testgui '/Users/mcuee/bin/bin' libtool: install: /opt/homebrew/bin/ginstall -c .libs/hidapi-testgui /Users/mcuee/bin/bin/hidapi-testgui make[2]: Nothing to be done for `install-data-am'. make[2]: Nothing to be done for `install-exec-am'. /opt/homebrew/bin/gmkdir -p '/Users/mcuee/bin/share/doc/hidapi' /opt/homebrew/bin/ginstall -c -m 644 ../README.md ../AUTHORS.txt ../LICENSE-bsd.txt ../LICENSE-gpl3.txt ../LICENSE-orig.txt ../LICENSE.txt '/Users/mcuee/bin/share/doc/hidapi' /opt/homebrew/bin/gmkdir -p '/Users/mcuee/bin/lib/pkgconfig' /opt/homebrew/bin/ginstall -c -m 644 pc/hidapi.pc '/Users/mcuee/bin/lib/pkgconfig' ```
mcuee commented 2021-08-28 21:27:57 -05:00 (Migrated from github.com)

Screenshot 2021-08-29 at 10 27 21 AM

![Screenshot 2021-08-29 at 10 27 21 AM](https://user-images.githubusercontent.com/1294740/131236188-c8d0bf5f-0e8f-4b32-aabf-36983b1ef6ad.png)
mcuee commented 2021-08-28 23:56:23 -05:00 (Migrated from github.com)

Looks the warning about signature is fatal. The others may not be a real issue.

bundling /opt/homebrew/opt/fox/lib/libFOX-1.6.0.dylib because it's in the list.
/Library/Developer/CommandLineTools/usr/bin/install_name_tool: warning: changes being made to the file will invalidate the code signature in: /Users/mcuee/build/hidapi/hidapi/build_autotool/testgui/TestGUI.app/Contents/MacOS/libFOX-1.6.0.dylib

Crash log:

Process:               hidapi-testgui [13427]
Path:                  /Users/USER/*/TestGUI.app/Contents/MacOS/hidapi-testgui
Identifier:            us.signal11.hidtestgui
Version:               1.0
Code Type:             ARM-64 (Native)
Parent Process:        ??? [1]
Responsible:           hidapi-testgui [13427]
User ID:               501

Date/Time:             2021-08-29 12:49:52.892 +0800
OS Version:            macOS 11.5.2 (20G95)
Report Version:        12
Anonymous UUID:        42E4176B-6AC7-D4CA-E9DC-A4B9DEA90EE3

Sleep/Wake UUID:       D9BE8A4A-53DE-4DD8-830F-7C0182A495BB

Time Awake Since Boot: 5800 seconds
Time Since Wake:       690 seconds

System Integrity Protection: enabled

Crashed Thread:        0

Exception Type:        EXC_BAD_ACCESS (Code Signature Invalid)
Exception Codes:       0x0000000000000032, 0x0000000104b64000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    Namespace CODESIGNING, Code 0x2

kernel messages:

VM Regions Near 0x104b64000:
    __LINKEDIT                  104b5c000-104b64000    [   32K] r--/r-- SM=COW  /Users/*/TestGUI.app/Contents/MacOS/hidapi-testgui
--> mapped file                 104b64000-104b68000    [   16K] r--/r-x SM=PRV  Object_id=25c655a3
    __TEXT                      104b80000-104b84000    [   16K] r-x/rwx SM=COW  /Users/*/*.dylib

Application Specific Information:
dyld: launch, loading dependent libraries
@executable_path/libFOX-1.6.0.dylib
Looks the warning about signature is fatal. The others may not be a real issue. ``` bundling /opt/homebrew/opt/fox/lib/libFOX-1.6.0.dylib because it's in the list. /Library/Developer/CommandLineTools/usr/bin/install_name_tool: warning: changes being made to the file will invalidate the code signature in: /Users/mcuee/build/hidapi/hidapi/build_autotool/testgui/TestGUI.app/Contents/MacOS/libFOX-1.6.0.dylib ``` Crash log: ``` Process: hidapi-testgui [13427] Path: /Users/USER/*/TestGUI.app/Contents/MacOS/hidapi-testgui Identifier: us.signal11.hidtestgui Version: 1.0 Code Type: ARM-64 (Native) Parent Process: ??? [1] Responsible: hidapi-testgui [13427] User ID: 501 Date/Time: 2021-08-29 12:49:52.892 +0800 OS Version: macOS 11.5.2 (20G95) Report Version: 12 Anonymous UUID: 42E4176B-6AC7-D4CA-E9DC-A4B9DEA90EE3 Sleep/Wake UUID: D9BE8A4A-53DE-4DD8-830F-7C0182A495BB Time Awake Since Boot: 5800 seconds Time Since Wake: 690 seconds System Integrity Protection: enabled Crashed Thread: 0 Exception Type: EXC_BAD_ACCESS (Code Signature Invalid) Exception Codes: 0x0000000000000032, 0x0000000104b64000 Exception Note: EXC_CORPSE_NOTIFY Termination Reason: Namespace CODESIGNING, Code 0x2 kernel messages: VM Regions Near 0x104b64000: __LINKEDIT 104b5c000-104b64000 [ 32K] r--/r-- SM=COW /Users/*/TestGUI.app/Contents/MacOS/hidapi-testgui --> mapped file 104b64000-104b68000 [ 16K] r--/r-x SM=PRV Object_id=25c655a3 __TEXT 104b80000-104b84000 [ 16K] r-x/rwx SM=COW /Users/*/*.dylib Application Specific Information: dyld: launch, loading dependent libraries @executable_path/libFOX-1.6.0.dylib ```
mcuee commented 2021-08-29 00:07:29 -05:00 (Migrated from github.com)

No such signature warning under x64 build.

hidapi/build_auto_x64 on  master [?] took 11s ❯ make
/Library/Developer/CommandLineTools/usr/bin/make  all-recursive
Making all in mac
  CC       hid.lo
  CCLD     libhidapi.la
Making all in hidtest
  CC       test.o
  CCLD     hidtest
Making all in testgui
  CXX      test.o
  OBJC     mac_support_cocoa.o
  CXXLD    hidapi-testgui
../../testgui/copy_to_bundle.sh
libtool: warning: '../mac/libhidapi.la' has not been installed in '/Users/mcuee/binx64/lib'
libtool: install: cp .libs/hidapi-testgui /Users/mcuee/build/hidapi/hidapi/build_auto_x64/testgui/TestGUI.app/Contents/MacOS/hidapi-testgui
bundling /usr/local/opt/fox/lib/libFOX-1.6.0.dylib because it's in the list.
bundling @executable_path/libFOX-1.6.0.dylib because it's in the list.
make[2]: Nothing to be done for `all-am'.
No such signature warning under x64 build. ``` hidapi/build_auto_x64 on  master [?] took 11s ❯ make /Library/Developer/CommandLineTools/usr/bin/make all-recursive Making all in mac CC hid.lo CCLD libhidapi.la Making all in hidtest CC test.o CCLD hidtest Making all in testgui CXX test.o OBJC mac_support_cocoa.o CXXLD hidapi-testgui ../../testgui/copy_to_bundle.sh libtool: warning: '../mac/libhidapi.la' has not been installed in '/Users/mcuee/binx64/lib' libtool: install: cp .libs/hidapi-testgui /Users/mcuee/build/hidapi/hidapi/build_auto_x64/testgui/TestGUI.app/Contents/MacOS/hidapi-testgui bundling /usr/local/opt/fox/lib/libFOX-1.6.0.dylib because it's in the list. bundling @executable_path/libFOX-1.6.0.dylib because it's in the list. make[2]: Nothing to be done for `all-am'. ```
mcuee commented 2021-08-29 00:35:58 -05:00 (Migrated from github.com)

There is apparently a differnce between an ARM64 build and x86_64 build. Probably this issue can not be sorted out without being a Apple macOS developer. I can self sign it but I am not so sure how to fix the bad signature issue of the dylib.

hidapi/build_autotool on  master [?] took 2s ❯ codesign --verify --deep --verbose=2 ../build_auto_x64/testgui/TestGUI.app
../build_auto_x64/testgui/TestGUI.app: code object is not signed at all
In architecture: x86_64

hidapi/build_autotool on  master [?] ❯ codesign --verify --deep --verbose=2 ./testgui/TestGUI.app
./testgui/TestGUI.app: code has no resources but signature indicates they must be present

hidapi/build_autotool on  master [?] ❯ codesign -s - --deep --verbose=2 ./testgui/TestGUI.app                                      
./testgui/TestGUI.app: signed app bundle with Mach-O thin (arm64) [us.signal11.hidtestgui]

hidapi/build_autotool on  master [?] ❯ codesign --verify --deep --verbose=2 ./testgui/TestGUI.app/Contents/MacOS/libFOX-1.6.0.dylib 
./testgui/TestGUI.app/Contents/MacOS/libFOX-1.6.0.dylib: invalid signature (code or signature have been modified)
In architecture: arm64
There is apparently a differnce between an ARM64 build and x86_64 build. Probably this issue can not be sorted out without being a Apple macOS developer. I can self sign it but I am not so sure how to fix the bad signature issue of the dylib. ``` hidapi/build_autotool on  master [?] took 2s ❯ codesign --verify --deep --verbose=2 ../build_auto_x64/testgui/TestGUI.app ../build_auto_x64/testgui/TestGUI.app: code object is not signed at all In architecture: x86_64 hidapi/build_autotool on  master [?] ❯ codesign --verify --deep --verbose=2 ./testgui/TestGUI.app ./testgui/TestGUI.app: code has no resources but signature indicates they must be present hidapi/build_autotool on  master [?] ❯ codesign -s - --deep --verbose=2 ./testgui/TestGUI.app ./testgui/TestGUI.app: signed app bundle with Mach-O thin (arm64) [us.signal11.hidtestgui] hidapi/build_autotool on  master [?] ❯ codesign --verify --deep --verbose=2 ./testgui/TestGUI.app/Contents/MacOS/libFOX-1.6.0.dylib ./testgui/TestGUI.app/Contents/MacOS/libFOX-1.6.0.dylib: invalid signature (code or signature have been modified) In architecture: arm64 ```
todbot commented 2021-08-29 00:36:17 -05:00 (Migrated from github.com)

Nice tip. But I do not know how to apply the same tip to GUI applications which relies on multiple libraries.

Apologies, I only really read your last post before I replied. The dual -arch CFLAGS must be done for all binaries being created (including shared libs). If you're using libraries you don't fully control or can specify the build style for, then you'll have to create two different executables.

> Nice tip. But I do not know how to apply the same tip to GUI applications which relies on multiple libraries. Apologies, I only really read your last post before I replied. The dual `-arch` CFLAGS must be done for all binaries being created (including shared libs). If you're using libraries you don't fully control or can specify the build style for, then you'll have to create two different executables.
mcuee commented 2021-08-29 04:06:26 -05:00 (Migrated from github.com)

No problem. It is okay to use two different executables in this case.

Just wondering who knows how to fix the invalid signature problem on the ARM64 (Apple Silicon) side.

No problem. It is okay to use two different executables in this case. Just wondering who knows how to fix the invalid signature problem on the ARM64 (Apple Silicon) side.
Youw commented 2021-09-04 10:06:15 -05:00 (Migrated from github.com)

Even if I copy the necessary dylib files to the TestGUI.app/Contents/MacOS folder to be in the same directory with hidapi-testgui, TestGui.app will still crash as it still wants to find /usr/local/lib files which are of x64 arch.

Try: otool -l <your binary/executable>
You'll get a list of all kind of things, including the list of dynamic libraries your binary links too statically (LC_LOAD_DYLIB section):

  • Some of them will be listed as an absolute paths, e.g.: /usr/lib/libSystem.B.dylib - there is no way to hack/inject the usage of those, unless replacing the file itself;
  • Some of them will be listed as a relative path, e.g.: @rpath/libhidapi.0.dylib; those are searched relatively to RPATH (or RUNPATH);
  • List of RPATHs or RUNPATHs is always hardcoded into the binary itself (unlike in linux, where you configure ldconfig) - LC_RPATH section;

DYLD_LIBRARY_PATH is probably the only way to extend the list of RPATHs (and Apple has deprecated its usage, and it is really hard to use it properly nowadays; it is a separate topic - I won't start it now), but even it won't work for dependencies that are listed as an absolute paths;

The only way to tweak you binary to use propper set of libraries (after it was built/linked) - is to use install_name_tool, either by -change <old> <new> the path to dependent library or by -delete_rpath <old>/-add_rpath <new> list or RPATH where to search for the dependent libraries.

That of course unvalidates the file signature, so it has to be done before signing.


@mcuee I haven't tried to describe the full story of how this all things works on macOS, but this should be enough for you to play around and try to make it work.

> Even if I copy the necessary dylib files to the TestGUI.app/Contents/MacOS folder to be in the same directory with hidapi-testgui, TestGui.app will still crash as it still wants to find /usr/local/lib files which are of x64 arch. Try: `otool -l <your binary/executable>` You'll get a list of all kind of things, including the list of dynamic libraries your binary links too statically (`LC_LOAD_DYLIB` section): - Some of them will be listed as an absolute paths, e.g.: `/usr/lib/libSystem.B.dylib` - there is no way to hack/inject the usage of those, unless replacing the file itself; - Some of them will be listed as a relative path, e.g.: `@rpath/libhidapi.0.dylib`; those are searched relatively to [RPATH](https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/RunpathDependentLibraries.html) (or RUNPATH); - List of `RPATH`s or `RUNPATH`s is always hardcoded into the binary itself (unlike in linux, where you configure ldconfig) - `LC_RPATH` section; `DYLD_LIBRARY_PATH` is probably the only way to extend the list of `RPATH`s (and Apple has deprecated its usage, and it is really hard to use it properly nowadays; it is a separate topic - I won't start it now), but even it won't work for dependencies that are listed as an absolute paths; The only way to tweak you binary to use propper set of libraries (after it was built/linked) - is to use [`install_name_tool`](https://www.unix.com/man-page/osx/1/install_name_tool/), either by `-change <old> <new>` the path to dependent library or by `-delete_rpath <old>/-add_rpath <new>` list or `RPATH` where to search for the dependent libraries. That of course unvalidates the file signature, so it has to be done before signing. --- @mcuee I haven't tried to describe the full story of how this all things works on macOS, but this _should_ be enough for you to play around and try to make it work.
mcuee commented 2021-09-04 20:47:35 -05:00 (Migrated from github.com)

Thanks. I will try the tip to see if I can get it work or not.

Thanks. I will try the tip to see if I can get it work or not.
mcuee commented 2021-09-05 09:03:29 -05:00 (Migrated from github.com)

This diff fixed the issue for me under my Mac Mini M1 -- at least I can run the TestGUI.app now, even if I copy the app to the /Application directory.

The two warnings does not seem to cause issues.

hidapi on  master [!?] via △ v3.21.2 ❯ git diff
diff --git a/testgui/copy_to_bundle.sh b/testgui/copy_to_bundle.sh
index ddff64f..7085bcc 100755
--- a/testgui/copy_to_bundle.sh
+++ b/testgui/copy_to_bundle.sh
@@ -11,7 +11,8 @@ EXEPATH=$PWD/TestGUI.app/Contents/MacOS
 # may not be in /opt/local. One per line. These
 # are used with grep, so only a portion of the name
 # is required. eg: libFOX, libz, etc.
-LIBS_TO_BUNDLE=libFOX
+#LIBS_TO_BUNDLE=libFOX
+LIBS_TO_BUNDLE=
 
 
 function copydeps {

hidapi/build_autotool on  master [!?] ❯ make
/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-recursive
Making all in mac
  CC       hid.lo
  CCLD     libhidapi.la
Making all in hidtest
  CC       test.o
  CCLD     hidtest
Making all in testgui
  CXX      test.o
  OBJC     mac_support_cocoa.o
  CXXLD    hidapi-testgui
ld: warning: ignoring file /usr/local/lib/libjpeg.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file /usr/local/lib/libtiff.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
../../testgui/copy_to_bundle.sh
libtool: install: cp .libs/hidapi-testgui /Users/mcuee/build/hidapi/hidapi/build_autotool/testgui/TestGUI.app/Contents/MacOS/hidapi-testgui
make[2]: Nothing to be done for `all-am'.
This diff fixed the issue for me under my Mac Mini M1 -- at least I can run the TestGUI.app now, even if I copy the app to the /Application directory. The two warnings does not seem to cause issues. ``` hidapi on  master [!?] via △ v3.21.2 ❯ git diff diff --git a/testgui/copy_to_bundle.sh b/testgui/copy_to_bundle.sh index ddff64f..7085bcc 100755 --- a/testgui/copy_to_bundle.sh +++ b/testgui/copy_to_bundle.sh @@ -11,7 +11,8 @@ EXEPATH=$PWD/TestGUI.app/Contents/MacOS # may not be in /opt/local. One per line. These # are used with grep, so only a portion of the name # is required. eg: libFOX, libz, etc. -LIBS_TO_BUNDLE=libFOX +#LIBS_TO_BUNDLE=libFOX +LIBS_TO_BUNDLE= function copydeps { hidapi/build_autotool on  master [!?] ❯ make /Applications/Xcode.app/Contents/Developer/usr/bin/make all-recursive Making all in mac CC hid.lo CCLD libhidapi.la Making all in hidtest CC test.o CCLD hidtest Making all in testgui CXX test.o OBJC mac_support_cocoa.o CXXLD hidapi-testgui ld: warning: ignoring file /usr/local/lib/libjpeg.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64 ld: warning: ignoring file /usr/local/lib/libtiff.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64 ../../testgui/copy_to_bundle.sh libtool: install: cp .libs/hidapi-testgui /Users/mcuee/build/hidapi/hidapi/build_autotool/testgui/TestGUI.app/Contents/MacOS/hidapi-testgui make[2]: Nothing to be done for `all-am'. ```
mcuee commented 2021-09-05 09:12:24 -05:00 (Migrated from github.com)

That being said, I think it is not properly done as the libhidapi.0.dylib is hardcoded to "/Users/mcuee/bin/lib/libhidapi.0.dylib" which I installed to as part of the build process.

click for more details of otool output
/Applications🔒 ❯ otool -l ./TestGUI_m1.app/Contents/MacOS/hidapi-testgui 
./TestGUI_m1.app/Contents/MacOS/hidapi-testgui:
Load command 0
      cmd LC_SEGMENT_64
  cmdsize 72
  segname __PAGEZERO
   vmaddr 0x0000000000000000
   vmsize 0x0000000100000000
  fileoff 0
 filesize 0
  maxprot 0x00000000
 initprot 0x00000000
   nsects 0
    flags 0x0
Load command 1
      cmd LC_SEGMENT_64
  cmdsize 1032
  segname __TEXT
   vmaddr 0x0000000100000000
   vmsize 0x0000000000008000
  fileoff 0
 filesize 32768
  maxprot 0x00000005
 initprot 0x00000005
   nsects 12
    flags 0x0
Section
  sectname __text
   segname __TEXT
      addr 0x0000000100003c58
      size 0x0000000000002400
    offset 15448
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x80000400
 reserved1 0
 reserved2 0
Section
  sectname __stubs
   segname __TEXT
      addr 0x0000000100006058
      size 0x0000000000000384
    offset 24664
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x80000408
 reserved1 0 (index into indirect symbol table)
 reserved2 12 (size of stubs)
Section
  sectname __stub_helper
   segname __TEXT
      addr 0x00000001000063dc
      size 0x0000000000000384
    offset 25564
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x80000400
 reserved1 0
 reserved2 0
Section
  sectname __objc_methlist
   segname __TEXT
      addr 0x0000000100006760
      size 0x0000000000000044
    offset 26464
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __gcc_except_tab
   segname __TEXT
      addr 0x00000001000067a4
      size 0x00000000000005ac
    offset 26532
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __cstring
   segname __TEXT
      addr 0x0000000100006d50
      size 0x0000000000000592
    offset 27984
     align 2^0 (1)
    reloff 0
    nreloc 0
     flags 0x00000002
 reserved1 0
 reserved2 0
Section
  sectname __const
   segname __TEXT
      addr 0x00000001000072e2
      size 0x000000000000000d
    offset 29410
     align 2^0 (1)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __objc_classname
   segname __TEXT
      addr 0x00000001000072ef
      size 0x000000000000002d
    offset 29423
     align 2^0 (1)
    reloff 0
    nreloc 0
     flags 0x00000002
 reserved1 0
 reserved2 0
Section
  sectname __objc_methname
   segname __TEXT
      addr 0x000000010000731c
      size 0x000000000000074b
    offset 29468
     align 2^0 (1)
    reloff 0
    nreloc 0
     flags 0x00000002
 reserved1 0
 reserved2 0
Section
  sectname __objc_methtype
   segname __TEXT
      addr 0x0000000100007a67
      size 0x0000000000000403
    offset 31335
     align 2^0 (1)
    reloff 0
    nreloc 0
     flags 0x00000002
 reserved1 0
 reserved2 0
Section
  sectname __unwind_info
   segname __TEXT
      addr 0x0000000100007e6c
      size 0x0000000000000144
    offset 32364
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __eh_frame
   segname __TEXT
      addr 0x0000000100007fb0
      size 0x0000000000000050
    offset 32688
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Load command 2
      cmd LC_SEGMENT_64
  cmdsize 552
  segname __DATA_CONST
   vmaddr 0x0000000100008000
   vmsize 0x0000000000004000
  fileoff 32768
 filesize 16384
  maxprot 0x00000003
 initprot 0x00000003
   nsects 6
    flags 0x10
Section
  sectname __got
   segname __DATA_CONST
      addr 0x0000000100008000
      size 0x0000000000000048
    offset 32768
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000006
 reserved1 75 (index into indirect symbol table)
 reserved2 0
Section
  sectname __mod_init_func
   segname __DATA_CONST
      addr 0x0000000100008048
      size 0x0000000000000008
    offset 32840
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000009
 reserved1 0
 reserved2 0
Section
  sectname __const
   segname __DATA_CONST
      addr 0x0000000100008050
      size 0x0000000000000290
    offset 32848
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __objc_classlist
   segname __DATA_CONST
      addr 0x00000001000082e0
      size 0x0000000000000008
    offset 33504
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x10000000
 reserved1 0
 reserved2 0
Section
  sectname __objc_protolist
   segname __DATA_CONST
      addr 0x00000001000082e8
      size 0x0000000000000010
    offset 33512
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __objc_imageinfo
   segname __DATA_CONST
      addr 0x00000001000082f8
      size 0x0000000000000008
    offset 33528
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Load command 3
      cmd LC_SEGMENT_64
  cmdsize 712
  segname __DATA
   vmaddr 0x000000010000c000
   vmsize 0x0000000000004000
  fileoff 49152
 filesize 16384
  maxprot 0x00000003
 initprot 0x00000003
   nsects 8
    flags 0x0
Section
  sectname __la_symbol_ptr
   segname __DATA
      addr 0x000000010000c000
      size 0x0000000000000258
    offset 49152
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000007
 reserved1 84 (index into indirect symbol table)
 reserved2 0
Section
  sectname __objc_const
   segname __DATA
      addr 0x000000010000c258
      size 0x00000000000008e8
    offset 49752
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __objc_selrefs
   segname __DATA
      addr 0x000000010000cb40
      size 0x0000000000000058
    offset 52032
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x10000005
 reserved1 0
 reserved2 0
Section
  sectname __objc_classrefs
   segname __DATA
      addr 0x000000010000cb98
      size 0x0000000000000020
    offset 52120
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x10000000
 reserved1 0
 reserved2 0
Section
  sectname __objc_data
   segname __DATA
      addr 0x000000010000cbb8
      size 0x0000000000000050
    offset 52152
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __data
   segname __DATA
      addr 0x000000010000cc08
      size 0x00000000000000c8
    offset 52232
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __common
   segname __DATA
      addr 0x000000010000ccd0
      size 0x0000000000000030
    offset 0
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000001
 reserved1 0
 reserved2 0
Section
  sectname __bss
   segname __DATA
      addr 0x000000010000cd00
      size 0x0000000000000010
    offset 0
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000001
 reserved1 0
 reserved2 0
Load command 4
      cmd LC_SEGMENT_64
  cmdsize 72
  segname __LINKEDIT
   vmaddr 0x0000000100010000
   vmsize 0x0000000000008000
  fileoff 65536
 filesize 22539
  maxprot 0x00000001
 initprot 0x00000001
   nsects 0
    flags 0x0
Load command 5
            cmd LC_DYLD_INFO_ONLY
        cmdsize 48
     rebase_off 65536
    rebase_size 184
       bind_off 65720
      bind_size 4832
  weak_bind_off 70552
 weak_bind_size 48
  lazy_bind_off 0
 lazy_bind_size 0
     export_off 70600
    export_size 992
Load command 6
     cmd LC_SYMTAB
 cmdsize 24
  symoff 71640
   nsyms 376
  stroff 78296
 strsize 8952
Load command 7
            cmd LC_DYSYMTAB
        cmdsize 80
      ilocalsym 0
      nlocalsym 209
     iextdefsym 209
     nextdefsym 30
      iundefsym 239
      nundefsym 137
         tocoff 0
           ntoc 0
      modtaboff 0
        nmodtab 0
   extrefsymoff 0
    nextrefsyms 0
 indirectsymoff 77656
  nindirectsyms 159
      extreloff 0
        nextrel 0
      locreloff 0
        nlocrel 0
Load command 8
          cmd LC_LOAD_DYLINKER
      cmdsize 32
         name /usr/lib/dyld (offset 12)
Load command 9
     cmd LC_UUID
 cmdsize 24
    uuid 99EB4106-6212-3AAD-80C3-928E07A1C789
Load command 10
      cmd LC_BUILD_VERSION
  cmdsize 32
 platform 1
    minos 11.0
      sdk 11.3
   ntools 1
     tool 3
  version 650.9
Load command 11
      cmd LC_SOURCE_VERSION
  cmdsize 16
  version 0.0
Load command 12
       cmd LC_MAIN
   cmdsize 24
  entryoff 23644
 stacksize 0
Load command 13
          cmd LC_LOAD_DYLIB
      cmdsize 64
         name /Users/mcuee/bin/lib/libhidapi.0.dylib (offset 24)
   time stamp 2 Thu Jan  1 07:30:02 1970
      current version 1.0.0
compatibility version 1.0.0
Load command 14
          cmd LC_LOAD_DYLIB
      cmdsize 72
         name /opt/homebrew/opt/fox/lib/libFOX-1.6.0.dylib (offset 24)
   time stamp 2 Thu Jan  1 07:30:02 1970
      current version 1.56.0
compatibility version 1.0.0
Load command 15
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /opt/X11/lib/libX11.6.dylib (offset 24)
   time stamp 2 Thu Jan  1 07:30:02 1970
      current version 11.0.0
compatibility version 11.0.0
Load command 16
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /opt/X11/lib/libXext.6.dylib (offset 24)
   time stamp 2 Thu Jan  1 07:30:02 1970
      current version 11.0.0
compatibility version 11.0.0
Load command 17
          cmd LC_LOAD_DYLIB
      cmdsize 64
         name /opt/X11/lib/libfreetype.6.dylib (offset 24)
   time stamp 2 Thu Jan  1 07:30:02 1970
      current version 24.4.0
compatibility version 24.0.0
Load command 18
          cmd LC_LOAD_DYLIB
      cmdsize 64
         name /opt/X11/lib/libfontconfig.1.dylib (offset 24)
   time stamp 2 Thu Jan  1 07:30:02 1970
      current version 14.0.0
compatibility version 14.0.0
Load command 19
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /opt/X11/lib/libXft.2.dylib (offset 24)
   time stamp 2 Thu Jan  1 07:30:02 1970
      current version 6.3.0
compatibility version 6.0.0
Load command 20
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /opt/X11/lib/libXcursor.1.dylib (offset 24)
   time stamp 2 Thu Jan  1 07:30:02 1970
      current version 2.2.0
compatibility version 2.0.0
Load command 21
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /opt/X11/lib/libXrender.1.dylib (offset 24)
   time stamp 2 Thu Jan  1 07:30:02 1970
      current version 5.0.0
compatibility version 5.0.0
Load command 22
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /opt/X11/lib/libXrandr.2.dylib (offset 24)
   time stamp 2 Thu Jan  1 07:30:02 1970
      current version 5.0.0
compatibility version 5.0.0
Load command 23
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /opt/X11/lib/libXfixes.3.dylib (offset 24)
   time stamp 2 Thu Jan  1 07:30:02 1970
      current version 5.0.0
compatibility version 5.0.0
Load command 24
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /opt/X11/lib/libXi.6.dylib (offset 24)
   time stamp 2 Thu Jan  1 07:30:02 1970
      current version 8.0.0
compatibility version 8.0.0
Load command 25
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /usr/lib/libSystem.B.dylib (offset 24)
   time stamp 2 Thu Jan  1 07:30:02 1970
      current version 1292.100.5
compatibility version 1.0.0
Load command 26
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /opt/X11/lib/libpng16.16.dylib (offset 24)
   time stamp 2 Thu Jan  1 07:30:02 1970
      current version 55.0.0
compatibility version 55.0.0
Load command 27
          cmd LC_LOAD_DYLIB
      cmdsize 48
         name /usr/lib/libz.1.dylib (offset 24)
   time stamp 2 Thu Jan  1 07:30:02 1970
      current version 1.2.11
compatibility version 1.0.0
Load command 28
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /usr/lib/libbz2.1.0.dylib (offset 24)
   time stamp 2 Thu Jan  1 07:30:02 1970
      current version 1.0.5
compatibility version 1.0.0
Load command 29
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /opt/X11/lib/libGLU.1.dylib (offset 24)
   time stamp 2 Thu Jan  1 07:30:02 1970
      current version 5.1.0
compatibility version 5.0.0
Load command 30
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /opt/X11/lib/libGL.1.dylib (offset 24)
   time stamp 2 Thu Jan  1 07:30:02 1970
      current version 4.0.0
compatibility version 4.0.0
Load command 31
          cmd LC_LOAD_DYLIB
      cmdsize 88
         name /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (offset 24)
   time stamp 2 Thu Jan  1 07:30:02 1970
      current version 23.0.0
compatibility version 1.0.0
Load command 32
          cmd LC_LOAD_DYLIB
      cmdsize 88
         name /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (offset 24)
   time stamp 2 Thu Jan  1 07:30:02 1970
      current version 2022.44.149
compatibility version 45.0.0
Load command 33
          cmd LC_LOAD_DYLIB
      cmdsize 104
         name /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (offset 24)
   time stamp 2 Thu Jan  1 07:30:02 1970
      current version 1775.118.101
compatibility version 150.0.0
Load command 34
          cmd LC_LOAD_DYLIB
      cmdsize 88
         name /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (offset 24)
   time stamp 2 Thu Jan  1 07:30:02 1970
      current version 275.0.0
compatibility version 1.0.0
Load command 35
          cmd LC_LOAD_DYLIB
      cmdsize 48
         name /usr/lib/libc++.1.dylib (offset 24)
   time stamp 2 Thu Jan  1 07:30:02 1970
      current version 905.6.0
compatibility version 1.0.0
Load command 36
          cmd LC_LOAD_DYLIB
      cmdsize 96
         name /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (offset 24)
   time stamp 2 Thu Jan  1 07:30:02 1970
      current version 1775.118.101
compatibility version 300.0.0
Load command 37
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /usr/lib/libobjc.A.dylib (offset 24)
   time stamp 2 Thu Jan  1 07:30:02 1970
      current version 228.0.0
compatibility version 1.0.0
Load command 38
      cmd LC_FUNCTION_STARTS
  cmdsize 16
  dataoff 71592
 datasize 48
Load command 39
      cmd LC_DATA_IN_CODE
  cmdsize 16
  dataoff 71640
 datasize 0
Load command 40
      cmd LC_CODE_SIGNATURE
  cmdsize 16
  dataoff 87248
 datasize 827

That being said, I think it is not properly done as the libhidapi.0.dylib is hardcoded to "/Users/mcuee/bin/lib/libhidapi.0.dylib" which I installed to as part of the build process. <details> <summary> click for more details of otool output </summary> ``` /Applications🔒 ❯ otool -l ./TestGUI_m1.app/Contents/MacOS/hidapi-testgui ./TestGUI_m1.app/Contents/MacOS/hidapi-testgui: Load command 0 cmd LC_SEGMENT_64 cmdsize 72 segname __PAGEZERO vmaddr 0x0000000000000000 vmsize 0x0000000100000000 fileoff 0 filesize 0 maxprot 0x00000000 initprot 0x00000000 nsects 0 flags 0x0 Load command 1 cmd LC_SEGMENT_64 cmdsize 1032 segname __TEXT vmaddr 0x0000000100000000 vmsize 0x0000000000008000 fileoff 0 filesize 32768 maxprot 0x00000005 initprot 0x00000005 nsects 12 flags 0x0 Section sectname __text segname __TEXT addr 0x0000000100003c58 size 0x0000000000002400 offset 15448 align 2^2 (4) reloff 0 nreloc 0 flags 0x80000400 reserved1 0 reserved2 0 Section sectname __stubs segname __TEXT addr 0x0000000100006058 size 0x0000000000000384 offset 24664 align 2^2 (4) reloff 0 nreloc 0 flags 0x80000408 reserved1 0 (index into indirect symbol table) reserved2 12 (size of stubs) Section sectname __stub_helper segname __TEXT addr 0x00000001000063dc size 0x0000000000000384 offset 25564 align 2^2 (4) reloff 0 nreloc 0 flags 0x80000400 reserved1 0 reserved2 0 Section sectname __objc_methlist segname __TEXT addr 0x0000000100006760 size 0x0000000000000044 offset 26464 align 2^3 (8) reloff 0 nreloc 0 flags 0x00000000 reserved1 0 reserved2 0 Section sectname __gcc_except_tab segname __TEXT addr 0x00000001000067a4 size 0x00000000000005ac offset 26532 align 2^2 (4) reloff 0 nreloc 0 flags 0x00000000 reserved1 0 reserved2 0 Section sectname __cstring segname __TEXT addr 0x0000000100006d50 size 0x0000000000000592 offset 27984 align 2^0 (1) reloff 0 nreloc 0 flags 0x00000002 reserved1 0 reserved2 0 Section sectname __const segname __TEXT addr 0x00000001000072e2 size 0x000000000000000d offset 29410 align 2^0 (1) reloff 0 nreloc 0 flags 0x00000000 reserved1 0 reserved2 0 Section sectname __objc_classname segname __TEXT addr 0x00000001000072ef size 0x000000000000002d offset 29423 align 2^0 (1) reloff 0 nreloc 0 flags 0x00000002 reserved1 0 reserved2 0 Section sectname __objc_methname segname __TEXT addr 0x000000010000731c size 0x000000000000074b offset 29468 align 2^0 (1) reloff 0 nreloc 0 flags 0x00000002 reserved1 0 reserved2 0 Section sectname __objc_methtype segname __TEXT addr 0x0000000100007a67 size 0x0000000000000403 offset 31335 align 2^0 (1) reloff 0 nreloc 0 flags 0x00000002 reserved1 0 reserved2 0 Section sectname __unwind_info segname __TEXT addr 0x0000000100007e6c size 0x0000000000000144 offset 32364 align 2^2 (4) reloff 0 nreloc 0 flags 0x00000000 reserved1 0 reserved2 0 Section sectname __eh_frame segname __TEXT addr 0x0000000100007fb0 size 0x0000000000000050 offset 32688 align 2^3 (8) reloff 0 nreloc 0 flags 0x00000000 reserved1 0 reserved2 0 Load command 2 cmd LC_SEGMENT_64 cmdsize 552 segname __DATA_CONST vmaddr 0x0000000100008000 vmsize 0x0000000000004000 fileoff 32768 filesize 16384 maxprot 0x00000003 initprot 0x00000003 nsects 6 flags 0x10 Section sectname __got segname __DATA_CONST addr 0x0000000100008000 size 0x0000000000000048 offset 32768 align 2^3 (8) reloff 0 nreloc 0 flags 0x00000006 reserved1 75 (index into indirect symbol table) reserved2 0 Section sectname __mod_init_func segname __DATA_CONST addr 0x0000000100008048 size 0x0000000000000008 offset 32840 align 2^3 (8) reloff 0 nreloc 0 flags 0x00000009 reserved1 0 reserved2 0 Section sectname __const segname __DATA_CONST addr 0x0000000100008050 size 0x0000000000000290 offset 32848 align 2^3 (8) reloff 0 nreloc 0 flags 0x00000000 reserved1 0 reserved2 0 Section sectname __objc_classlist segname __DATA_CONST addr 0x00000001000082e0 size 0x0000000000000008 offset 33504 align 2^3 (8) reloff 0 nreloc 0 flags 0x10000000 reserved1 0 reserved2 0 Section sectname __objc_protolist segname __DATA_CONST addr 0x00000001000082e8 size 0x0000000000000010 offset 33512 align 2^3 (8) reloff 0 nreloc 0 flags 0x00000000 reserved1 0 reserved2 0 Section sectname __objc_imageinfo segname __DATA_CONST addr 0x00000001000082f8 size 0x0000000000000008 offset 33528 align 2^2 (4) reloff 0 nreloc 0 flags 0x00000000 reserved1 0 reserved2 0 Load command 3 cmd LC_SEGMENT_64 cmdsize 712 segname __DATA vmaddr 0x000000010000c000 vmsize 0x0000000000004000 fileoff 49152 filesize 16384 maxprot 0x00000003 initprot 0x00000003 nsects 8 flags 0x0 Section sectname __la_symbol_ptr segname __DATA addr 0x000000010000c000 size 0x0000000000000258 offset 49152 align 2^3 (8) reloff 0 nreloc 0 flags 0x00000007 reserved1 84 (index into indirect symbol table) reserved2 0 Section sectname __objc_const segname __DATA addr 0x000000010000c258 size 0x00000000000008e8 offset 49752 align 2^3 (8) reloff 0 nreloc 0 flags 0x00000000 reserved1 0 reserved2 0 Section sectname __objc_selrefs segname __DATA addr 0x000000010000cb40 size 0x0000000000000058 offset 52032 align 2^3 (8) reloff 0 nreloc 0 flags 0x10000005 reserved1 0 reserved2 0 Section sectname __objc_classrefs segname __DATA addr 0x000000010000cb98 size 0x0000000000000020 offset 52120 align 2^3 (8) reloff 0 nreloc 0 flags 0x10000000 reserved1 0 reserved2 0 Section sectname __objc_data segname __DATA addr 0x000000010000cbb8 size 0x0000000000000050 offset 52152 align 2^3 (8) reloff 0 nreloc 0 flags 0x00000000 reserved1 0 reserved2 0 Section sectname __data segname __DATA addr 0x000000010000cc08 size 0x00000000000000c8 offset 52232 align 2^3 (8) reloff 0 nreloc 0 flags 0x00000000 reserved1 0 reserved2 0 Section sectname __common segname __DATA addr 0x000000010000ccd0 size 0x0000000000000030 offset 0 align 2^3 (8) reloff 0 nreloc 0 flags 0x00000001 reserved1 0 reserved2 0 Section sectname __bss segname __DATA addr 0x000000010000cd00 size 0x0000000000000010 offset 0 align 2^3 (8) reloff 0 nreloc 0 flags 0x00000001 reserved1 0 reserved2 0 Load command 4 cmd LC_SEGMENT_64 cmdsize 72 segname __LINKEDIT vmaddr 0x0000000100010000 vmsize 0x0000000000008000 fileoff 65536 filesize 22539 maxprot 0x00000001 initprot 0x00000001 nsects 0 flags 0x0 Load command 5 cmd LC_DYLD_INFO_ONLY cmdsize 48 rebase_off 65536 rebase_size 184 bind_off 65720 bind_size 4832 weak_bind_off 70552 weak_bind_size 48 lazy_bind_off 0 lazy_bind_size 0 export_off 70600 export_size 992 Load command 6 cmd LC_SYMTAB cmdsize 24 symoff 71640 nsyms 376 stroff 78296 strsize 8952 Load command 7 cmd LC_DYSYMTAB cmdsize 80 ilocalsym 0 nlocalsym 209 iextdefsym 209 nextdefsym 30 iundefsym 239 nundefsym 137 tocoff 0 ntoc 0 modtaboff 0 nmodtab 0 extrefsymoff 0 nextrefsyms 0 indirectsymoff 77656 nindirectsyms 159 extreloff 0 nextrel 0 locreloff 0 nlocrel 0 Load command 8 cmd LC_LOAD_DYLINKER cmdsize 32 name /usr/lib/dyld (offset 12) Load command 9 cmd LC_UUID cmdsize 24 uuid 99EB4106-6212-3AAD-80C3-928E07A1C789 Load command 10 cmd LC_BUILD_VERSION cmdsize 32 platform 1 minos 11.0 sdk 11.3 ntools 1 tool 3 version 650.9 Load command 11 cmd LC_SOURCE_VERSION cmdsize 16 version 0.0 Load command 12 cmd LC_MAIN cmdsize 24 entryoff 23644 stacksize 0 Load command 13 cmd LC_LOAD_DYLIB cmdsize 64 name /Users/mcuee/bin/lib/libhidapi.0.dylib (offset 24) time stamp 2 Thu Jan 1 07:30:02 1970 current version 1.0.0 compatibility version 1.0.0 Load command 14 cmd LC_LOAD_DYLIB cmdsize 72 name /opt/homebrew/opt/fox/lib/libFOX-1.6.0.dylib (offset 24) time stamp 2 Thu Jan 1 07:30:02 1970 current version 1.56.0 compatibility version 1.0.0 Load command 15 cmd LC_LOAD_DYLIB cmdsize 56 name /opt/X11/lib/libX11.6.dylib (offset 24) time stamp 2 Thu Jan 1 07:30:02 1970 current version 11.0.0 compatibility version 11.0.0 Load command 16 cmd LC_LOAD_DYLIB cmdsize 56 name /opt/X11/lib/libXext.6.dylib (offset 24) time stamp 2 Thu Jan 1 07:30:02 1970 current version 11.0.0 compatibility version 11.0.0 Load command 17 cmd LC_LOAD_DYLIB cmdsize 64 name /opt/X11/lib/libfreetype.6.dylib (offset 24) time stamp 2 Thu Jan 1 07:30:02 1970 current version 24.4.0 compatibility version 24.0.0 Load command 18 cmd LC_LOAD_DYLIB cmdsize 64 name /opt/X11/lib/libfontconfig.1.dylib (offset 24) time stamp 2 Thu Jan 1 07:30:02 1970 current version 14.0.0 compatibility version 14.0.0 Load command 19 cmd LC_LOAD_DYLIB cmdsize 56 name /opt/X11/lib/libXft.2.dylib (offset 24) time stamp 2 Thu Jan 1 07:30:02 1970 current version 6.3.0 compatibility version 6.0.0 Load command 20 cmd LC_LOAD_DYLIB cmdsize 56 name /opt/X11/lib/libXcursor.1.dylib (offset 24) time stamp 2 Thu Jan 1 07:30:02 1970 current version 2.2.0 compatibility version 2.0.0 Load command 21 cmd LC_LOAD_DYLIB cmdsize 56 name /opt/X11/lib/libXrender.1.dylib (offset 24) time stamp 2 Thu Jan 1 07:30:02 1970 current version 5.0.0 compatibility version 5.0.0 Load command 22 cmd LC_LOAD_DYLIB cmdsize 56 name /opt/X11/lib/libXrandr.2.dylib (offset 24) time stamp 2 Thu Jan 1 07:30:02 1970 current version 5.0.0 compatibility version 5.0.0 Load command 23 cmd LC_LOAD_DYLIB cmdsize 56 name /opt/X11/lib/libXfixes.3.dylib (offset 24) time stamp 2 Thu Jan 1 07:30:02 1970 current version 5.0.0 compatibility version 5.0.0 Load command 24 cmd LC_LOAD_DYLIB cmdsize 56 name /opt/X11/lib/libXi.6.dylib (offset 24) time stamp 2 Thu Jan 1 07:30:02 1970 current version 8.0.0 compatibility version 8.0.0 Load command 25 cmd LC_LOAD_DYLIB cmdsize 56 name /usr/lib/libSystem.B.dylib (offset 24) time stamp 2 Thu Jan 1 07:30:02 1970 current version 1292.100.5 compatibility version 1.0.0 Load command 26 cmd LC_LOAD_DYLIB cmdsize 56 name /opt/X11/lib/libpng16.16.dylib (offset 24) time stamp 2 Thu Jan 1 07:30:02 1970 current version 55.0.0 compatibility version 55.0.0 Load command 27 cmd LC_LOAD_DYLIB cmdsize 48 name /usr/lib/libz.1.dylib (offset 24) time stamp 2 Thu Jan 1 07:30:02 1970 current version 1.2.11 compatibility version 1.0.0 Load command 28 cmd LC_LOAD_DYLIB cmdsize 56 name /usr/lib/libbz2.1.0.dylib (offset 24) time stamp 2 Thu Jan 1 07:30:02 1970 current version 1.0.5 compatibility version 1.0.0 Load command 29 cmd LC_LOAD_DYLIB cmdsize 56 name /opt/X11/lib/libGLU.1.dylib (offset 24) time stamp 2 Thu Jan 1 07:30:02 1970 current version 5.1.0 compatibility version 5.0.0 Load command 30 cmd LC_LOAD_DYLIB cmdsize 56 name /opt/X11/lib/libGL.1.dylib (offset 24) time stamp 2 Thu Jan 1 07:30:02 1970 current version 4.0.0 compatibility version 4.0.0 Load command 31 cmd LC_LOAD_DYLIB cmdsize 88 name /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (offset 24) time stamp 2 Thu Jan 1 07:30:02 1970 current version 23.0.0 compatibility version 1.0.0 Load command 32 cmd LC_LOAD_DYLIB cmdsize 88 name /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (offset 24) time stamp 2 Thu Jan 1 07:30:02 1970 current version 2022.44.149 compatibility version 45.0.0 Load command 33 cmd LC_LOAD_DYLIB cmdsize 104 name /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (offset 24) time stamp 2 Thu Jan 1 07:30:02 1970 current version 1775.118.101 compatibility version 150.0.0 Load command 34 cmd LC_LOAD_DYLIB cmdsize 88 name /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (offset 24) time stamp 2 Thu Jan 1 07:30:02 1970 current version 275.0.0 compatibility version 1.0.0 Load command 35 cmd LC_LOAD_DYLIB cmdsize 48 name /usr/lib/libc++.1.dylib (offset 24) time stamp 2 Thu Jan 1 07:30:02 1970 current version 905.6.0 compatibility version 1.0.0 Load command 36 cmd LC_LOAD_DYLIB cmdsize 96 name /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (offset 24) time stamp 2 Thu Jan 1 07:30:02 1970 current version 1775.118.101 compatibility version 300.0.0 Load command 37 cmd LC_LOAD_DYLIB cmdsize 56 name /usr/lib/libobjc.A.dylib (offset 24) time stamp 2 Thu Jan 1 07:30:02 1970 current version 228.0.0 compatibility version 1.0.0 Load command 38 cmd LC_FUNCTION_STARTS cmdsize 16 dataoff 71592 datasize 48 Load command 39 cmd LC_DATA_IN_CODE cmdsize 16 dataoff 71640 datasize 0 Load command 40 cmd LC_CODE_SIGNATURE cmdsize 16 dataoff 87248 datasize 827 ``` </details>
Youw commented 2021-09-05 14:27:15 -05:00 (Migrated from github.com)

Yeah, it isn't.
To build it properly - a lot of tweaking need to be done for autotools scripts, which I'd rather not touch.

CMake build off-the-box likely won't properly work too, but CMake has a lot of convetient machanism to configure it easily.
I will do so if/when we have Qt-based GUI.

Yeah, it isn't. To build it properly - a lot of tweaking need to be done for autotools scripts, which I'd rather not touch. CMake build off-the-box likely won't properly work too, but CMake has a lot of convetient machanism to configure it easily. I will do so if/when we have Qt-based GUI.
mcuee commented 2021-09-12 23:43:41 -05:00 (Migrated from github.com)

I will still keep this issue closed for now. Ad the testgui build itself is okay and runs properly under macOS (x64 and ARM64), only the application bundle is not generated properly.

I will still keep this issue closed for now. Ad the testgui build itself is okay and runs properly under macOS (x64 and ARM64), only the application bundle is not generated properly.
JustJoostNL commented 2023-01-14 14:04:23 -06:00 (Migrated from github.com)

I still have this issue, is there already a solution?

I still have this issue, is there already a solution?
Lewiscowles1986 commented 2023-07-29 06:19:28 -05:00 (Migrated from github.com)

So I'm trying to use python ctypes to load the built obj file.

import ctypes

ctypes.cdll.LoadLibrary('hid.o')

this then gives me a number of errors; but an important (I feel) error reads

unloadable mach-o file type 1 'hid.o'

I built using the guide to clone, cd mac, make -f Makefile-manual

Is this some weirdo OSX security issue, or something else?

The sample program builds and runs enumerating devices, so I don't doubt that hidapi works if I call it from C

So I'm trying to use python ctypes to load the built obj file. ``` import ctypes ctypes.cdll.LoadLibrary('hid.o') ``` this then gives me a number of errors; but an important (I feel) error reads > unloadable mach-o file type 1 'hid.o' I built using the guide to clone, cd mac, `make -f Makefile-manual` Is this some weirdo OSX security issue, or something else? The sample program builds and runs enumerating devices, so I don't doubt that hidapi works if I call it from C
mcuee commented 2026-05-01 21:52:17 -05:00 (Migrated from github.com)

Now it failed to build with latest macOS 26.4.1.

mcuee in ~/build/libusb/hidapi/build_autotools on master % sw_vers 
ProductName:		macOS
ProductVersion:		26.4.1
BuildVersion:		25E253

mcuee in ~/build/libusb/hidapi/build_autotools on master % make -i 
/Library/Developer/CommandLineTools/usr/bin/make  all-recursive
Making all in mac
make[2]: Nothing to be done for `all'.
Making all in hidtest
make[2]: Nothing to be done for `all'.
Making all in testgui
  OBJC     mac_support_cocoa.o
../../testgui/mac_support_cocoa.m:47:9: error: cannot initialize return object of type
      'NSApplicationTerminateReply' with an rvalue of type 'BOOL' (aka 'bool')
   47 |         return YES;
      |                ^~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/objc/objc.h:96:13: note: expanded
      from macro 'YES'
   96 | #define YES __objc_yes
      |             ^~~~~~~~~~
1 error generated.
make[2]: [mac_support_cocoa.o] Error 1 (ignored)
  CXXLD    hidapi-testgui
clang++: error: no such file or directory: 'mac_support_cocoa.o'
make[2]: [hidapi-testgui] Error 1 (ignored)
../../testgui/copy_to_bundle.sh
libtool: install: cp hidapi-testgui /Users/mcuee/build/libusb/hidapi/build_autotools/testgui/TestGUI.app/Contents/MacOS/hidapi-testgui
cp: hidapi-testgui: No such file or directory
error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: /Users/mcuee/build/libusb/hidapi/build_autotools/testgui/TestGUI.app/Contents/MacOS/hidapi-testgui (No such file or directory)
Now it failed to build with latest macOS 26.4.1. ``` mcuee in ~/build/libusb/hidapi/build_autotools on master % sw_vers ProductName: macOS ProductVersion: 26.4.1 BuildVersion: 25E253 mcuee in ~/build/libusb/hidapi/build_autotools on master % make -i /Library/Developer/CommandLineTools/usr/bin/make all-recursive Making all in mac make[2]: Nothing to be done for `all'. Making all in hidtest make[2]: Nothing to be done for `all'. Making all in testgui OBJC mac_support_cocoa.o ../../testgui/mac_support_cocoa.m:47:9: error: cannot initialize return object of type 'NSApplicationTerminateReply' with an rvalue of type 'BOOL' (aka 'bool') 47 | return YES; | ^~~ /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/objc/objc.h:96:13: note: expanded from macro 'YES' 96 | #define YES __objc_yes | ^~~~~~~~~~ 1 error generated. make[2]: [mac_support_cocoa.o] Error 1 (ignored) CXXLD hidapi-testgui clang++: error: no such file or directory: 'mac_support_cocoa.o' make[2]: [hidapi-testgui] Error 1 (ignored) ../../testgui/copy_to_bundle.sh libtool: install: cp hidapi-testgui /Users/mcuee/build/libusb/hidapi/build_autotools/testgui/TestGUI.app/Contents/MacOS/hidapi-testgui cp: hidapi-testgui: No such file or directory error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: /Users/mcuee/build/libusb/hidapi/build_autotools/testgui/TestGUI.app/Contents/MacOS/hidapi-testgui (No such file or directory) ```
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-libusb/hidapi#151
No description provided.