Skip to content

Building a universal library for macOS #473

Answered by fdidron
fdidron asked this question in Q&A
Discussion options

You must be logged in to vote

Well I found a way to do it with cmake right after posting this, maybe this can be helpful.

Add the CMAKE_OSX_ARCHITECTURES=x86_64;arm64 to the cmake command.

Following the Cmake building guide:

# Executed from the root of the repository
mkdir build
cmake .. -DCMAKE_OSX_ARCHITECTURES=x86_64;arm64
cmake --build .
cmake --build . --target install

To make sure the result is a universal lib, run file /usr/local/lib/libhidapi.dylib you should see

Mach-O universal binary with 2 architectures:
[x86_64:Mach-O 64-bit dynamically linked shared library x86_64]
[arm64:Mach-O 64-bit dynamically linked shared library arm64]

Edited to add @Youw suggestion.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Youw
Comment options

@fdidron
Comment options

Answer selected by fdidron
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants