我转而使用premake5,而不是直接使用Visual 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" }但是,我仍然会收到链接器错误。
发布于 2019-03-08 00:25:36
DLPDev基本上是正确的。
*在指定库时,应省略系统特定的装饰,如前缀或文件扩展名。预制作将根据目标平台自动合成正确的格式。该规则的一个例外是Mac框架,在该框架中,需要文件扩展名才能将其标识为此。
由于我对过滤器功能的无知,我犯了一个重大的错误。在发布过滤器之后调用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函数的范围
https://stackoverflow.com/questions/55039294
复制相似问题