我能够编译一个简单的程序,只需调用vkCreateInstance
with MinGW-64
。
也许你得到的错误与-m64
标志有关。
按照下面我的配置:
- 视窗 8.1
- NetBeans IDE 8.1
- Vulkan SDK 1.0.3.1
- gcc 版本 5.3.0(x86_64-posix-seh-rev0,由 MinGW-W64 项目构建)
使用 g++:
编译:
g++ -m64 -std=c++11 -c -g -I/C/VulkanSDK/1.0.3.1/Include -MMD -MP -MF "build/Debug/MinGW-Windows/main.o.d" -o build/Debug/MinGW-Windows/main.o main.c
关联:
g++ -m64 -std=c++11 -o dist/Debug/MinGW-Windows/vulkanfirsttest build/Debug/MinGW-Windows/main.o -L/C/VulkanSDK/1.0.3.1/Bin -lvulkan-1
使用 gcc:
编译:
gcc -m64 -c -g -I/C/VulkanSDK/1.0.3.1/Include -std=c11 -MMD -MP -MF "build/Debug/MinGW-Windows/main.o.d" -o build/Debug/MinGW-Windows/main.o main.c
关联:
gcc -m64 -o dist/Debug/MinGW-Windows/vulkanfirsttest build/Debug/MinGW-Windows/main.o -L/C/VulkanSDK/1.0.3.1/Bin -lvulkan-1
源代码:
#include <stdio.h>
#include <stdlib.h>
#include <vulkan/vulkan.h>
int main(int argc, char *argv[]) {
VkInstanceCreateInfo vk_info;
VkInstance inst = 0;
VkResult res;
vk_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
vk_info.pNext = NULL;
vk_info.pApplicationInfo = NULL;
vk_info.enabledLayerCount = 0;
vk_info.ppEnabledLayerNames = NULL;
vk_info.enabledExtensionCount = 0;
vk_info.ppEnabledExtensionNames = NULL;
res = vkCreateInstance(&vk_info, NULL, &inst);
if (res != VK_SUCCESS) {
// Error!
printf("Error %d\n", res);
return 1;
};
printf("Device created: %p\n", inst);
vkDestroyInstance(inst, NULL);
return (EXIT_SUCCESS);
}
输出:
Device created: 0000000000534FD0