Last active
September 8, 2022 13:10
-
-
Save vaiorabbit/6204931 to your computer and use it in GitHub Desktop.
Building libglfw.dylib on macOS (Apple Silicon)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl -L https://github.com/glfw/glfw/releases/download/3.3.2/glfw-3.3.2.zip > glfw-3.3.2.zip | |
$ unzip glfw-3.3.2.zip | |
$ cd glfw-3.3.2/ | |
$ mkdir build | |
$ cd build | |
$ export MACOSX_DEPLOYMENT_TARGET=10.14 | |
$ cmake -D CMAKE_BUILD_TYPE=Release -D GLFW_NATIVE_API=1 -D CMAKE_OSX_ARCHITECTURES="x86_64;arm64" -D BUILD_SHARED_LIBS=ON -D CMAKE_C_COMPILER=clang ../ | |
$ make | |
$ ls -l src/libglfw* | |
-rwxr-xr-x 1 foo staff 626904 12 20 17:31 src/libglfw.3.3.dylib | |
lrwxr-xr-x 1 foo staff 17 12 20 17:31 src/libglfw.3.dylib -> libglfw.3.3.dylib | |
lrwxr-xr-x 1 foo staff 15 12 20 17:31 src/libglfw.dylib -> libglfw.3.dylib | |
$ file src/libglfw.dylib | |
src/libglfw.dylib: 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] | |
src/libglfw.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64 | |
src/libglfw.dylib (for architecture arm64): Mach-O 64-bit dynamically linked shared library arm64 | |
$ clang --version | |
Apple clang version 12.0.0 (clang-1200.0.32.28) | |
Target: arm64-apple-darwin20.1.0 | |
Thread model: posix | |
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin |
Saved me too! Changed it for Snow Leopard, but this was so useful!
Great, you saved my day :) (OSX 10.9)
Nice Summary.
cmake -D BUILD_SHARED_LIBS=ON ./ would do fine too!
worked great on 10.9! However, i did get this alert:
CMake Warning:
Manually-specified variables were not used by the project:
GLFW_NATIVE_API
Still was able to build it though!
Thank you so much!
I needed to build GLFW from source to get around an issue in macOS Sierra (GLFW first responder error). By default it only built libglfw3.a. The GLFW build instructions just say “do what you would normally do” — normally I just install it with brew! I had no idea what to do until I found your gist. I just changed the deploy target to 10.12, followed the make
with a make install
and all was good.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this saved me! thank you