我试图编译包含在Vulkan的第一个程序,所以我粘贴它变成在vs17 RC一个新的Win32项目。它在Samples dir中称为01-init_instance。我正在编译x86。福尔康vkresult链接错误MSVC
#include <iostream>
#include <cstdlib>
#include <util_init.hpp>
#define APP_SHORT_NAME "vulkansamples_instance"
int main(int argc, char *argv[]) {
struct sample_info info = {};
init_global_layer_properties(info);
/* VULKAN_KEY_START */
// initialize the VkApplicationInfo structure
VkApplicationInfo app_info = {};
app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
app_info.pNext = NULL;
app_info.pApplicationName = APP_SHORT_NAME;
app_info.applicationVersion = 1;
app_info.pEngineName = APP_SHORT_NAME;
app_info.engineVersion = 1;
app_info.apiVersion = VK_API_VERSION_1_0;
// initialize the VkInstanceCreateInfo structure
VkInstanceCreateInfo inst_info = {};
inst_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
inst_info.pNext = NULL;
inst_info.flags = 0;
inst_info.pApplicationInfo = &app_info;
inst_info.enabledExtensionCount = 0;
inst_info.ppEnabledExtensionNames = NULL;
inst_info.enabledLayerCount = 0;
inst_info.ppEnabledLayerNames = NULL;
VkInstance inst;
VkResult res;
res = vkCreateInstance(&inst_info, NULL, &inst);
if (res == VK_ERROR_INCOMPATIBLE_DRIVER) {
std::cout << "cannot find a compatible Vulkan ICD\n";
exit(-1);
}
else if (res) {
std::cout << "unknown error\n";
exit(-1);
}
vkDestroyInstance(inst, NULL);
/* VULKAN_KEY_END */
return 0;
}
我已经做了该项目的属性,如:
我为vkCreateInstance这个错误,并得到了链接错误没有被解决(在依赖加入的.lib前)现在我得到一个单一的,不同的链接器错误没有找到vkResult。这让我困惑,因为我不知道它如何解决vkcreate而不是vkresult。我使用了所有字符集设置(多字节,而不是正常的unicode),但是这并没有改变任何东西。
错误是:
错误LNK2019解析的外部符号在函数_main中引用 “枚举VkResult __cdecl init_global_layer_properties(结构sample_info &)”(init_global_layer_properties @@ YA AW4VkResult @@ AAUsample_info @@@ Z?) vktest C:\用户\用户\文件\的Visual Studio 2017 \项目\ vktest \ vktest \ Source.obj 1
我会怎么做删除这个需要? –
从你的代码中移除'#include',并使用其中的任何东西(例如'init_global_layer_properties')。 –
MuertoExcobito