CMakeLists.txt
find_package(Vulkan REQUIRED)
target_link_libraries(${PROJECT_NAME} INTERFACE Vulkan::Vulkan)
int 我的着色器.cpp
void OpenGLShader::Compile(const std::unordered_map<GLenum, std::string>& shaderSources)
{
vk::Buffer;
shaderc::Compiler compiler;
shaderc::CompileOptions options;
}
我尝试做的是测试这是否适用于shaderrc,但我收到了这些错误
out\build\x64-debug\GLContext.lib(OpenGLShader.cpp.obj) : error LNK2019: unresolved external symbol shaderc_compiler_release referenced in function "public: __cdecl shaderc::Compiler::~Compiler(void)" (??1Compiler@shaderc@@QEAA@XZ)
out\build\x64-debug\GLContext.lib(OpenGLShader.cpp.obj) : error LNK2019: unresolved external symbol shaderc_compile_options_initialize referenced in function "public: __cdecl shaderc::CompileOptions::CompileOptions(void)" (??0CompileOptions@shaderc@@QEAA@XZ)
\out\build\x64-debug\GLContext.lib(OpenGLShader.cpp.obj) : error LNK2019: unresolved external symbol shaderc_compile_options_initialize referenced in function "public: __cdecl shaderc::CompileOptions::CompileOptions(void)" (??0CompileOptions@shaderc@@QEAA@XZ)
\out\build\x64-debug\GLContext.lib(OpenGLShader.cpp.obj) : error LNK2019: unresolved external symbol shaderc_compile_options_release referenced in function "public: __cdecl shaderc::CompileOptions::~CompileOptions(void)" (??1CompileOptions@shaderc@@QEAA@XZ)
vk::Buffer;
这个工作正常,但是添加 shaderc
会导致这些错误,有人可以解释一下我错过了什么吗
shaderc
的静态库是FindVulkan
中可选组件的一部分,导入目标称为Vulkan::shaderc_combined
。
find_package(Vulkan REQUIRED)
target_link_libraries(${PROJECT_NAME} INTERFACE Vulkan::Vulkan Vulkan::shaderc_combined)
FindVulkan
还会定义Vulkan_shaderc_combined_FOUND
来指定它是否确实能够找到shaderc
静态库,以及它在Vulkan_shaderc_combined_LIBRARY
中的静态库路径。
如果您想使用动态库,则需要使用更手动的方法。您还需要在您的发行版中包含
shaderc_shared
动态库。如果您想要调试版本,还有 shaderc_sharedd
。
find_library(Vulkan_shaderc_LIBRARY NAMES shaderc PATHS ${VULKAN_SDK}/Lib)
find_library(Vulkan_shaderc_shared_LIBRARY NAMES shaderc_shared PATHS ${VULKAN_SDK}/Lib)
target_link_libraryes(${PROJECT_NAME} INTERFACE Vulkan::Vulkan Vulkan_shaderc_LIBRARY Vulkan_shaderc_shared_LIBRARY)