I am currently trying to learn C++ and thought doing some OpenGL magic would be a nice idea. I saw a Premake5 tutorial and followed along, except I tried linking a library myself (GLFW). When generating the project files for Visual Studio 2017, the library I specified somehow does not get properly linked into the project. I get lots a lots of LINK errors in the likes of:
glfw3.lib(monitor.c.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp__strdup" in Funktion "_glfwAllocMonitor".
glfw3.lib(win32_window.c.obj) : error LNK2001: Nicht aufgelöstes externes Symbol "__imp__strdup".
...
This is how my premake5.lua file looks like:
workspace "MojoEngine"
architecture "x64"
configurations
{
"Debug",
"Release",
"Dist"
}
outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"
project "MojoEngine"
location "MojoEngine"
kind "SharedLib"
language "C++"
targetdir ("bin/" .. outputdir .. "/%{prj.name}")
objdir ("bin-int/" .. outputdir .. "/%{prj.name}")
librarydir = "%{prj.name}/libraries/"
files
{
"%{prj.name}/src/**.h",
"%{prj.name}/src/**.cpp"
}
includedirs
{
librarydir .. "GLFW/include",
"%{prj.name}/vendor/spdlog/include"
}
libdirs
{
librarydir .. "GLFW/lib"
}
links
{
"glfw3",
"glfw3dll"
}
filter "system:windows"
cppdialect "C++17"
staticruntime "On"
systemversion "latest"
defines
{
"ME_PLATFORM_WINDOWS",
"ME_BUILD_DLL"
}
postbuildcommands
{
("{COPY} %{cfg.buildtarget.relpath} ../bin/" .. outputdir ..
"/Sandbox"),
("{COPY} %{prj.name}/lib/GLFW/glfw3.dll ../bin/" .. outputdir ..
"/Sandbox")
}
filter "configurations:Debug"
defines "ME_DEBUG"
symbols "On"
filter "configurations:Release"
defines "ME_RELEASE"
optimize "On"
filter "configurations:Dist"
defines "ME_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
{
"MojoEngine/vendor/spdlog/include",
"MojoEngine/src"
}
links
{
"MojoEngine"
}
filter "system:windows"
cppdialect "C++17"
staticruntime "On"
systemversion "latest"
defines
{
"ME_PLATFORM_WINDOWS",
}
filter "configurations:Debug"
defines "ME_DEBUG"
symbols "On"
filter "configurations:Release"
defines "ME_RELEASE"
optimize "On"
filter "configurations:Dist"
defines "ME_DIST"
optimize "On"