I’m trying to setup my project using premake but i’m getting some linking error with GLFW, here are the premake files:
premake file for GLFW lib:
<code>project "GLFW"
kind "StaticLib"
language "C"
targetdir ("%{wks.location}/bin/%{cfg.platform}_%{cfg.buildcfg}/%{prj.name}")
objdir ("%{wks.location}/bin-int/%{cfg.platform}_%{cfg.buildcfg}/%{prj.name}")
-- support only for MacOS
files {
"include/GLFW/glfw3.h",
"include/GLFW/glfw3native.h",
"src/glfw_config.h",
"src/context.c",
"src/init.c",
"src/input.c",
"src/monitor.c",
"src/vulkan.c",
"src/window.c",
"src/egl_context.c",
"src/osmesa_context.c",
"src/cocoa_time.c",
"src/posix_module.c",
"src/posix_thread.c",
"src/cocoa_init.m",
"src/cocoa_joystick.m",
"src/cocoa_monitor.m",
"src/cocoa_window.m",
"src/nsgl_context.m"
}
defines {
"_GLFW_COCOA"
}
</code>
<code>project "GLFW"
kind "StaticLib"
language "C"
targetdir ("%{wks.location}/bin/%{cfg.platform}_%{cfg.buildcfg}/%{prj.name}")
objdir ("%{wks.location}/bin-int/%{cfg.platform}_%{cfg.buildcfg}/%{prj.name}")
-- support only for MacOS
files {
"include/GLFW/glfw3.h",
"include/GLFW/glfw3native.h",
"src/glfw_config.h",
"src/context.c",
"src/init.c",
"src/input.c",
"src/monitor.c",
"src/vulkan.c",
"src/window.c",
"src/egl_context.c",
"src/osmesa_context.c",
"src/cocoa_time.c",
"src/posix_module.c",
"src/posix_thread.c",
"src/cocoa_init.m",
"src/cocoa_joystick.m",
"src/cocoa_monitor.m",
"src/cocoa_window.m",
"src/nsgl_context.m"
}
defines {
"_GLFW_COCOA"
}
</code>
project "GLFW"
kind "StaticLib"
language "C"
targetdir ("%{wks.location}/bin/%{cfg.platform}_%{cfg.buildcfg}/%{prj.name}")
objdir ("%{wks.location}/bin-int/%{cfg.platform}_%{cfg.buildcfg}/%{prj.name}")
-- support only for MacOS
files {
"include/GLFW/glfw3.h",
"include/GLFW/glfw3native.h",
"src/glfw_config.h",
"src/context.c",
"src/init.c",
"src/input.c",
"src/monitor.c",
"src/vulkan.c",
"src/window.c",
"src/egl_context.c",
"src/osmesa_context.c",
"src/cocoa_time.c",
"src/posix_module.c",
"src/posix_thread.c",
"src/cocoa_init.m",
"src/cocoa_joystick.m",
"src/cocoa_monitor.m",
"src/cocoa_window.m",
"src/nsgl_context.m"
}
defines {
"_GLFW_COCOA"
}
premake file for workspace and project:
<code>workspace "GLFWWindowWorkspace"
architecture "ARM64"
configurations {
"Debug",
"Release"
}
IncludeDir = {}
IncludeDir["glfw"] = "%{wks.location}/vendor/GLFW/include"
group "Dependencies"
include "vendor/GLFW"
group "Core"
project "GLFWWindow"
kind "ConsoleApp"
language "C++"
cppdialect "C++20"
targetdir ("%{wks.location}/bin/%{cfg.platform}_%{cfg.buildcfg}/%{prj.name}")
objdir ("%{wks.location}/bin-int/%{cfg.platform}_%{cfg.buildcfg}/%{prj.name}")
files {
"src/**.h",
"src/**.hpp",
"src/**.cpp"
}
includedirs {
"%{IncludeDir.glfw}"
}
links {
"OpenGL.framework",
"Cocoa.framework",
"IOKit.framework",
"CoreFoundation.framework",
"GLFW"
}
</code>
<code>workspace "GLFWWindowWorkspace"
architecture "ARM64"
configurations {
"Debug",
"Release"
}
IncludeDir = {}
IncludeDir["glfw"] = "%{wks.location}/vendor/GLFW/include"
group "Dependencies"
include "vendor/GLFW"
group "Core"
project "GLFWWindow"
kind "ConsoleApp"
language "C++"
cppdialect "C++20"
targetdir ("%{wks.location}/bin/%{cfg.platform}_%{cfg.buildcfg}/%{prj.name}")
objdir ("%{wks.location}/bin-int/%{cfg.platform}_%{cfg.buildcfg}/%{prj.name}")
files {
"src/**.h",
"src/**.hpp",
"src/**.cpp"
}
includedirs {
"%{IncludeDir.glfw}"
}
links {
"OpenGL.framework",
"Cocoa.framework",
"IOKit.framework",
"CoreFoundation.framework",
"GLFW"
}
</code>
workspace "GLFWWindowWorkspace"
architecture "ARM64"
configurations {
"Debug",
"Release"
}
IncludeDir = {}
IncludeDir["glfw"] = "%{wks.location}/vendor/GLFW/include"
group "Dependencies"
include "vendor/GLFW"
group "Core"
project "GLFWWindow"
kind "ConsoleApp"
language "C++"
cppdialect "C++20"
targetdir ("%{wks.location}/bin/%{cfg.platform}_%{cfg.buildcfg}/%{prj.name}")
objdir ("%{wks.location}/bin-int/%{cfg.platform}_%{cfg.buildcfg}/%{prj.name}")
files {
"src/**.h",
"src/**.hpp",
"src/**.cpp"
}
includedirs {
"%{IncludeDir.glfw}"
}
links {
"OpenGL.framework",
"Cocoa.framework",
"IOKit.framework",
"CoreFoundation.framework",
"GLFW"
}
and the linker error message:
ld: Undefined symbols:
OBJC_CLASS$_CAMetalLayer, referenced from:
in libGLFW.a6
__glfwSelectPlatform, referenced from:
_glfwInit in libGLFW.a9
Does anyone know how can i solve this issue.