I am having some issues linking GLFW to my project. I have spent about 3 1/2 Hours trying to find out what I have done wrong. It is a compile time error, so I cannot find out which functions are causing the issues. Here is my error log
2>GLFW.lib(window.obj) : error LNK2019: unresolved external symbol __imp_strncpy referenced in function glfwWindowHintString
2>GLFW.lib(input.obj) : error LNK2001: unresolved external symbol __imp_strncpy
2>GLFW.lib(win32_joystick.obj) : error LNK2001: unresolved external symbol __imp_strncpy
2>GLFW.lib(osmesa_context.obj) : error LNK2001: unresolved external symbol __imp__wassert
2>GLFW.lib(monitor.obj) : error LNK2001: unresolved external symbol __imp__wassert
2>GLFW.lib(vulkan.obj) : error LNK2001: unresolved external symbol __imp__wassert
2>GLFW.lib(wgl_context.obj) : error LNK2001: unresolved external symbol __imp__wassert
2>GLFW.lib(egl_context.obj) : error LNK2001: unresolved external symbol __imp__wassert
2>GLFW.lib(window.obj) : error LNK2001: unresolved external symbol __imp__wassert
2>GLFW.lib(context.obj) : error LNK2001: unresolved external symbol __imp__wassert
2>GLFW.lib(input.obj) : error LNK2001: unresolved external symbol __imp__wassert
2>GLFW.lib(win32_thread.obj) : error LNK2001: unresolved external symbol __imp__wassert
2>GLFW.lib(context.obj) : error LNK2019: unresolved external symbol __imp___stdio_common_vsscanf referenced in function sscanf
2>GLFW.lib(input.obj) : error LNK2019: unresolved external symbol __imp_strspn referenced in function glfwUpdateGamepadMappings
I am using premake, and Have a script for the engine/sandbox and another one for GLFW. Here is the main premake script
workspace "Gluten"
architecture "x64"
configurations
{
"Debug",
"Release",
"Dist"
}
outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"
IncludeDir = {}
IncludeDir["GLFW"] = "Gluten/vendor/GLFW/include"
include "Gluten/vendor/GLFW"
project "Gluten"
location "Gluten"
kind "SharedLib"
language "C++"
targetdir ("bin/" .. outputdir .. "/%{prj.name}")
objdir ("bin-int/" .. outputdir .. "/%{prj.name}")
pchheader "glutpch.h"
pchsource "Gluten/src/glutpch.cpp"
files
{
"%{prj.name}/src/**.h",
"%{prj.name}/src/**.cpp"
}
includedirs
{
"%{prj.name}/src",
"%{prj.name}/vendor/spdlog/include",
"%{IncludeDir.GLFW}"
}
links
{
"GLFW",
"opengl32.lib"
}
filter "system:windows"
cppdialect "C++17"
staticruntime "On"
systemversion "latest"
defines
{
"GLUT_PLATFORM_WINDOWS",
"GLUT_BUILD_DLL"
}
postbuildcommands
{
("{COPY} %{cfg.buildtarget.relpath} ../bin/" .. outputdir .. "/Sandbox")
}
filter "configurations:Debug"
defines "GLUT_DEBUG"
symbols "On"
filter "configurations:Release"
defines "GLUT_RELEASE"
optimize "On"
filter "configurations:Dist"
defines "GLUT_DIST"
optimize "On"
project "Sandbox"
location "Sandbox"
kind "ConsoleApp"
language "C++"
targetdir ("bin/" .. outputdir .. "/%{prj.name}")
objdir ("bin-int/" .. outputdir .. "/%{prj.name}")
files
{
"%{prj.name}/src/**.h",
"%{prj.name}/src/**.cpp"
}
includedirs
{
"Gluten/vendor/spdlog/include",
"Gluten/src"
}
links
{
"Gluten"
}
filter "system:windows"
cppdialect "C++17"
staticruntime "On"
systemversion "latest"
defines
{
"GLUT_PLATFORM_WINDOWS"
}
filter "configurations:Debug"
defines "GLUT_DEBUG"
symbols "On"
filter "configurations:Release"
defines "GLUT_RELEASE"
optimize "On"
filter "configurations:Dist"
defines "GLUT_DIST"
optimize "On"
And here is the script for glfw
project "GLFW"
kind "StaticLib"
language "C"
targetdir ("bin/" .. outputdir .. "/%{prj.name}")
objdir ("bin-int/" .. outputdir .. "/%{prj.name}")
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"
}
filter "system:linux"
pic "On"
systemversion "latest"
files
{
"src/x11_init.c",
"src/x11_monitor.c",
"src/x11_window.c",
"src/xkb_unicode.c",
"src/posix_time.c",
"src/posix_thread.c",
"src/glx_context.c",
"src/egl_context.c",
"src/osmesa_context.c",
"src/linux_joystick.c"
}
defines
{
"_GLFW_X11"
}
filter "system:windows"
systemversion "latest"
files
{
"src/win32_init.c",
"src/win32_joystick.c",
"src/win32_monitor.c",
"src/win32_time.c",
"src/win32_thread.c",
"src/win32_window.c",
"src/wgl_context.c",
"src/egl_context.c",
"src/osmesa_context.c"
}
defines
{
"_GLFW_WIN32",
"_CRT_SECURE_NO_WARNINGS"
}
links
{
"Dwmapi.lib"
}
filter "configurations:Debug"
runtime "Debug"
symbols "on"
filter "configurations:Release"
runtime "Release"
optimize "on"
The only code that I have to implement GLFW into the engine is a few lines of code
if (!s_GLFWInitialized)
{
// TODO: Error Checking
int success = glfwInit();
s_GLFWInitialized = true;
}
m_Window = glfwCreateWindow((int)props.Width, (int)props.Height, m_Data.Title.c_str(), nullptr, nullptr);
glfwMakeContextCurrent(m_Window);
glfwSetWindowUserPointer(m_Window, &m_Data);
SetVSync(true);
Thank you, any help is very much appreciated