Building GLFW from source on Mac 12.6 w/ Premake

I have a shared library project that I am trying to incorporate GLFW into. I have added GLFW as a submodule and created a premake file within to build it as a separate static library project and link it to my shared library. I have linked the necessary frameworks for Mac to use GLFW (Cocoa, OpenGL, and IOKit). I have also linked the “glfw” library for Mac. Here is the linker error:

Undefined symbols for architecture arm64:
  "Based::CreateApplication()", referenced from:
      _main in MacWindow.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Are there any ideas on how to fix this? MacWindow is within the shared library so it shouldn’t require a main function. I have scoured the internet and these forums but have been unsuccessful. I have found a user with the same exact problem as mine under the issues of the GLFW GitHub, here, without an answer. If necessary, I will add the premake files for both the shared library and the static library (GLFW).

To me it seems that the target which includes Based::CreateApplication was not built correctly for the architecture arm64. I don’t know if premake supports MacOS ARM64 (with universal binaries or without), and I can’t find any details on their site for this. This function isn’t part of GLFW, so a good starting point would be to check that you can make a simple “hello world” ARM64 application with premake and move from there.

If you’d like to try an alternative build approach you could look at this cmake starter for GLFW. Whilst premake is a superior build scripting language to cmake, cmake generally has wider support and GLFW has official build scripts for it.

Thank you for the reply dougbinks!

Before I included GLFW, the build was working perfectly fine with premake while Based::CreateApplication was incorporated. After a bit of fishing, I commented out the the Based::CreateApplication function and found the problem truly lied within the MacWindow file. It could not identify glfw3.h. Not 100% sure why, the MacWindow file has includedirs to the directory of GLFW. Although, now I have a completely working project with GLFW added as a submodule and built with premake.

Thank you for the help!

1 Like