我正在尝试编译一个使用 vulkan hpp 的程序,它在名为 vulkan_driver.h 的文件中使用一个方法,如下所示:
// Evaluate f and if result is not a success throw proper vk exception.
#define CHECK_VK_RESULT(x) do { \
vk::Result res = vk::Result(x); \
int tmp = 0; \
vk::createResultValue(res, tmp, __FILE__ ":" TOSTRING(__LINE__)); \
} while (0)
当我编译时出现以下错误:
[ 199s] In file included from /home/abuild/rpmbuild/BUILD/decaf-emu-20220508T212126/src/libgpu/src/vulkan/vulkan_driver.cpp:2:
[ 199s] /home/abuild/rpmbuild/BUILD/decaf-emu-20220508T212126/src/libgpu/src/vulkan/vulkan_driver.cpp: In member function 'void vulkan::Driver::initialise(vk::Instance, vk::PhysicalDevice, vk::Device, vk::Queue, uint32_t)':
[ 199s] /home/abuild/rpmbuild/BUILD/decaf-emu-20220508T212126/src/libgpu/src/vulkan/vulkan_driver.h:36:8: error: 'createResultValue' is not a member of 'vk'; did you mean 'createResultValueType'?
[ 199s] 36 | vk::createResultValue(res, tmp, __FILE__ ":" TOSTRING(__LINE__)); \
[ 199s] | ^~~~~~~~~~~~~~~~~
[ 199s] /home/abuild/rpmbuild/BUILD/decaf-emu-20220508T212126/src/libgpu/src/vulkan/vulkan_driver.cpp:89:4: note: in expansion of macro 'CHECK_VK_RESULT'
[ 199s] 89 | CHECK_VK_RESULT(vmaCreateAllocator(&allocatorCreateInfo, &mAllocator));
[ 199s] | ^~~~~~~~~~~~~~~
[ 199s] make[2]: *** [src/libgpu/CMakeFiles/libgpu.dir/build.make:647: src/libgpu/CMakeFiles/libgpu.dir/src/vulkan/vulkan_driver.cpp.o] Error 1
我该如何解决这个错误?
我在尝试构建https://github.com/jherico/Vulkan(在 Ubuntu 22.04 和 Windows 10 上)时遇到了同样的错误,
例如glfw.cpp 中的这一行导致了与 Ahmed Moselhi 发布的相同的编译错误。
我发现此函数的名称和签名已在 vulkan.hpp 中更改
(请参阅Github Vulkan-Headers 存储库中的此提交)
为了让编译再次工作,我需要改变函数的用法:
到:
在您的情况下@Ahmed Moselhi,您应该将代码更改为以下内容: