简体   繁体   中英

How to run vulkan example code in windows by mingw-w64?

everyone. I begin learn vulkan sdk programing in my window laptop rencently. I download the VulkanSDK-1.2.162.0, x86_64-8.1.0-release-win32-seh-rt_v6-rev0 and glfw-3.3.2.bin.WIN64, Unzip them and set the windows path, all is done and test resualt show in cmd like this:

C:\Users\Administrator>g++ --version
g++ (x86_64-win32-seh-rev0, Built by MinGW-W64 project) 8.1.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
C:\Users\Administrator>vulkaninfo
==========
VULKANINFO
==========

Vulkan Instance Version: 1.2.154


Instance Extensions: count = 11
===============================
        VK_EXT_debug_report                    : extension revision 9
        VK_EXT_debug_utils                     : extension revision 2
        VK_EXT_swapchain_colorspace            : extension revision 4
......
......
......

I am a beginner of c/c++ programing, in my basic understanding of the c/c++ complier workflow, it need the header file path and library path. So, I try to run vulkan's official cpp code in my machine with g++ command like this:

g++ -std=c++11 vlkantest.cpp -I D:\\Other\\Vulkan\\SDK_ROOT\\1.2.162.0\\Include -I D:\\Other\\mingw64\\include -I D:\\Other\\glfw-3.3.2.bin.WIN64\\include -L D:\\Other\\Vulkan\\SDK_ROOT\\1.2.162.0\\Lib -L D:\\Other\\mingw64\\lib -L D:\\Other\\glfw-3.3.2.bin.WIN64\\lib-mingw-w64

But, I just get the result like this:

g++ -std=c++11 vlkantest.cpp -I D:\\Other\\Vulkan\\SDK_ROOT\\1.2.162.0\\Include -I D:\\Other\\mingw64\\include -I D:\\Other\\glfw-3.3.2.bin.WIN64\\include -L D:\\Other\\Vulkan\\SDK_ROOT\\1.2.162.0\\Lib -L D:\\Other\\mingw64\\lib -L D:\\Other\\glfw-3.3.2.bin.WIN64\\lib-mingw-w64
C:\Users\ADMINI~1\AppData\Local\Temp\ccdv6xfT.o:vlkantest.cpp:(.text$_ZN24HelloTriangleApplication10initWindowEv[_ZN24HelloTriangleApplication10initWindowEv]+0xd): undefined reference to `glfwInit'
C:\Users\ADMINI~1\AppData\Local\Temp\ccdv6xfT.o:vlkantest.cpp:(.text$_ZN24HelloTriangleApplication10initWindowEv[_ZN24HelloTriangleApplication10initWindowEv]+0x1c): undefined reference to `glfwWindowHint'
C:\Users\ADMINI~1\AppData\Local\Temp\ccdv6xfT.o:vlkantest.cpp:(.text$_ZN24HelloTriangleApplication10initWindowEv[_ZN24HelloTriangleApplication10initWindowEv]+0x2b): undefined reference to `glfwWindowHint'
C:\Users\ADMINI~1\AppData\Local\Temp\ccdv6xfT.o:vlkantest.cpp:(.text$_ZN24HelloTriangleApplication10initWindowEv[_ZN24HelloTriangleApplication10initWindowEv]+0x50): undefined reference to `glfwCreateWindow'
C:\Users\ADMINI~1\AppData\Local\Temp\ccdv6xfT.o:vlkantest.cpp:(.text$_ZN24HelloTriangleApplication8mainLoopEv[_ZN24HelloTriangleApplication8mainLoopEv]+0x17): undefined reference to `glfwWindowShouldClose'
C:\Users\ADMINI~1\AppData\Local\Temp\ccdv6xfT.o:vlkantest.cpp:(.text$_ZN24HelloTriangleApplication8mainLoopEv[_ZN24HelloTriangleApplication8mainLoopEv]+0x25): undefined reference to `glfwPollEvents'
C:\Users\ADMINI~1\AppData\Local\Temp\ccdv6xfT.o:vlkantest.cpp:(.text$_ZN24HelloTriangleApplication7cleanupEv[_ZN24HelloTriangleApplication7cleanupEv]+0x17): undefined reference to `glfwDestroyWindow'
C:\Users\ADMINI~1\AppData\Local\Temp\ccdv6xfT.o:vlkantest.cpp:(.text$_ZN24HelloTriangleApplication7cleanupEv[_ZN24HelloTriangleApplication7cleanupEv]+0x1c): undefined reference to `glfwTerminate'
collect2.exe: error: ld returned 1 exit status

I think I miss some args for g++, Is anyone can point out my mistake in above g++ command? or just simply explain how this example code run in windows by mingw-w64? Thank a lot!

Seems like you have specified library folders but not actually linked the libraries. Have you tried adding -lglfw3 -lvulkan-1 to your compile command?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM