如何使用Vulkan与MinGW? (R_X86_64_32错误) [英] How do I use Vulkan with MinGW? (R_X86_64_32 error)
本文介绍了如何使用Vulkan与MinGW? (R_X86_64_32错误)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图设置一个裸机程序使用Vulkan。我安装了LunarG SDK。我有一个小程序,基本上只是调用 vkCreateInstance
。我用这一行编译:
I am trying to setup a bare bones program to use Vulkan. I installed the LunarG SDK. I have a tiny program that basically just calls vkCreateInstance
. I compiled with this line:
g++ -std=c++11 -I/c/VulkanSDK/1.0.3.1/Include -L/c/VulkanSDK/1.0.3.1/Bin main.cpp -lvulkan-1
这个编译器错误使用64位mingw(MSYS2):
I get this compiler error using 64-bit mingw (MSYS2):
relocation truncated to fit||R_X86_64_32 against symbol `__imp_vkCreateInstance' defined in .idata$5 section in C:\VulkanSDK\1.0.3.1\Bin/vulkan-1.lib(vulkan-1.dll.b)|
我该怎么办?我是否链接到正确的库?
What do I do? Am I linking against the right library?
推荐答案
我能够编译一个简单的程序,只需调用 vkCreateInstance
与 MinGW-64
。
I was able to compile a simple program, with just a call to vkCreateInstance
with MinGW-64
.
获取与 -m64
标志相关。
关注我的配置:
- Windows 8.1
- NetBeans IDE 8.1
- Vulkan SDK 1.0.3.1
- gcc版本5.3.0(x86_64-posix-seh-rev0,由MinGW-W64项目构建)
- Windows 8.1
- NetBeans IDE 8.1
- Vulkan SDK 1.0.3.1
- gcc version 5.3.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project)
使用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 -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);
}
输出:
装置已建立:0000000000534FD0
这篇关于如何使用Vulkan与MinGW? (R_X86_64_32错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文