[英]DirectX12 with Premake5: Linking Directx12 Static Libraries
我改用premake5,而不是直接使用Visual Studio 2017。
这是我过去与Dx12链接的方式。 我将这些宏放在main.cpp中,效果很好。
#pragma comment(lib, "d3d12.lib")
#pragma comment(lib, "dxgi.lib")
#pragma comment(lib, "d3dcompiler.lib")
但是,建议我不要在源代码中包含库。 在将项目转换为premake5时,我想知道处理这种情况的正确方法。
抱歉,我是premake5之类的工具的新手。 并且不确定如何进行。
更新1:我尝试添加以下代码来解决链接器错误。
print("Linking DX12 Libs")
libdirs {
os.findlib("d3d12.lib"),
os.findlib("dxgi.lib"),
os.findlib("d3dcompiler.lib") }
links { "d3d12.lib", "dxgi.lib", "d3dcompiler.lib" }
但是,我仍然收到链接器错误。
DLPDev主要*是正确的。
*指定库时,应省略系统特定的修饰,例如前缀或文件扩展名。 Premake会根据目标平台自动合成正确的格式。 该规则的一个例外是Mac OS X框架,其中需要文件扩展名来标识它。
由于对过滤器功能的不了解,我犯了一个严重的错误。 在发布过滤器之后,我才调用links
。 仅在发布模式下链接了dx12库。
-- This is all you need to link against dx12 there is no special sauce
-- You don't need to call libdirs or os.findlib for the dx12 libraries
-- This code works for both configurations since it is called before the filter function
links { "d3d12", "dxgi", "d3dcompiler" }
filter("configurations:Debug")
defines({ "DEBUG" })
symbols("On")
optimize("Off")
filter("configurations:Release")
defines({ "NDEBUG" })
symbols("On")`
TLDR:使用links
功能时,请注意不要包含文件扩展名。 并注意filter
功能的范围
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.