vulkan-guide icon indicating copy to clipboard operation
vulkan-guide copied to clipboard

Compile Error in vk_mem_alloc.h with VS2019

Open kobutri opened this issue 4 years ago • 5 comments
trafficstars

I downloaded the all-chapters branch configured the project with CMake for VS2019 and then set chapter 3 as startup project. When trying to compile I get a bunch of errors in vk_mem_alloc.h

image

kobutri avatar May 15 '21 13:05 kobutri

From monkeying about with the code, I seems to be due to some incompatibility between SDL and VMA. If you move the VMA include in vk_engine.cpp to be above the SDL include, it works.

Works

#define VMA_IMPLEMENTATION
#include "vk_mem_alloc.h"

#include <SDL.h>
#include <SDL_vulkan.h>

Fails with the errors above.

#include <SDL.h>
#include <SDL_vulkan.h>

#define VMA_IMPLEMENTATION
#include "vk_mem_alloc.h"

I'd need to investigate it more as to why its causing that, but at least this fix should allow you to continue working with the tutorial.

cdgiessen avatar May 15 '21 23:05 cdgiessen

Thank you so much.

kobutri avatar May 15 '21 23:05 kobutri

The same issue, looking forward to seeing why.

zheng95z avatar Jul 25 '21 08:07 zheng95z

I thought the problem is about the std::shared_mutex in VMA by a glance of the error msg, then add set(CMAKE_CXX_STANDARD 17) in CMakeList to force MSVC use 17 standard for compiling, and it works well. But it really confused me by way of swapping vma header with sdl...

Harold2017 avatar Sep 10 '21 07:09 Harold2017

Thanks for posting - this fixed it for me

OptimisticMonkey avatar Mar 14 '23 02:03 OptimisticMonkey