I’m trying to build glfw as a static library for my premake build process. It compiles, but when I link to to my main project I get this error:
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../lib/libmingw32.a(lib64_libmingw32_a-crtexewin.o): in function main’:`
C:/M/B/src/mingw-w64/mingw-w64-crt/crt/crtexewin.c:67:(.text.startup+0xbd): undefined reference to WinMain’`
Here is my premake file:
workspace "ThirdAttemptOpenGL"
architecture "x86_64"
startproject "ThirdAttemptOpenGL"
configurations { "Debug", "Release" }
flags
{
"MultiProcessorCompile"
}
outputbindir = "bin/%{cfg.system}-%{cfg.architecture}-%{cfg.buildcfg}/%{prj.name}"
outputobjdir = "bin-int/%{cfg.system}-%{cfg.architecture}-%{cfg.buildcfg}/%{prj.name}"
project "ThirdAttemptOpenGL"
location "ThirdAttemptOpenGL"
kind "ConsoleApp"
language "C++"
cppdialect "C++17"
staticruntime "on"
systemversion "latest"
targetdir (outputbindir)
objdir (outputobjdir)
files
{
"%{prj.location}/src/**.cpp",
"%{prj.location}/src/**.h"
}
includedirs
{
"%{wks.location}/external/glfw/include",
"%{wks.location}/external/glm",
}
defines
{
"GLFW_INCLUDE_NonE"
}
links
{
"glfw",
"opengl32"
}
filter "system:macosx"
links
{
"CoreFoundation.framework",
"Cocoa.framework",
"IOKit.framework",
"CoreVideo.framework"
}
filter "configurations:Debug"
runtime "Debug"
symbols "on"
filter "configurations:Release"
runtime "Release"
optimize "on"
group "Dependencies"
project "glfw"
location "external/glfw"
kind "StaticLib"
language "C"
staticruntime "on"
systemversion "latest"
targetdir (outputbindir)
objdir (outputobjdir)
files
{
"%{prj.location}/src/context.c",
"%{prj.location}/src/init.c",
"%{prj.location}/src/input.c",
"%{prj.location}/src/monitor.c",
"%{prj.location}/src/null_init.c",
"%{prj.location}/src/null_joystick.c",
"%{prj.location}/src/null_monitor.c",
"%{prj.location}/src/null_window.c",
"%{prj.location}/src/platform.c",
"%{prj.location}/src/vulkan.c",
"%{prj.location}/src/window.c",
}
filter "configurations:Debug"
runtime "Debug"
symbols "on"
filter "configurations:Release"
runtime "Release"
optimize "on"
filter "system:windows"
files
{
"%{prj.location}/src/wgl_context.c",
"%{prj.location}/src/wgl_context.h",
"%{prj.location}/src/win32_init.c",
"%{prj.location}/src/win32_joystick.c",
"%{prj.location}/src/win32_joystick.h",
"%{prj.location}/src/win32_monitor.c",
"%{prj.location}/src/win32_platform.h",
"%{prj.location}/src/win32_thread.c",
"%{prj.location}/src/win32_time.c",
"%{prj.location}/src/win32_window.c"
}
defines
{
"_GLFW_WIN32",
"_CRT_SECURE_NO_WARNINGS"
}
filter "system:linux"
files
{
"%{prj.location}/src/glx_context.c",
"%{prj.location}/src/glx_context.h",
"%{prj.location}/src/linux_joystick.c",
"%{prj.location}/src/linux_joystick.h",
"%{prj.location}/src/posix_time.c",
"%{prj.location}/src/posix_time.h",
"%{prj.location}/src/posix_thread.c",
"%{prj.location}/src/posix_thread.h",
"%{prj.location}/src/x11_init.c",
"%{prj.location}/src/x11_monitor.c",
"%{prj.location}/src/x11_platform.h",
"%{prj.location}/src/x11_window.c",
"%{prj.location}/src/xkb_unicode.c",
"%{prj.location}/src/xkb_unicode.h"
}
defines
{
"_GLFW_X11"
}
filter "system:macosx"
files
{
"%{prj.location}/src/cocoa_init.m",
"%{prj.location}/src/cocoa_joystick.m",
"%{prj.location}/src/cocoa_joystick.h",
"%{prj.location}/src/cocoa_monitor.m",
"%{prj.location}/src/cocoa_platform.h",
"%{prj.location}/src/cocoa_time.c",
"%{prj.location}/src/cocoa_window.m",
"%{prj.location}/src/nsgl_context.m",
"%{prj.location}/src/nsgl_context.h",
"%{prj.location}/src/posix_thread.c",
"%{prj.location}/src/posix_thread.h"
}
defines
{
"_GLFW_COCOA"
}
I would appreciate any help. Thank you guys.