VulkanMemoryAllocator-Hpp icon indicating copy to clipboard operation
VulkanMemoryAllocator-Hpp copied to clipboard

Cannot compile cpp module example with MSVC

Open Qendolin opened this issue 10 months ago • 0 comments

Trying to build the example fails with the following output (paths shortened):

====================[ Build | Modules-Example | Debug ]=========================
"C:\Program Files\CMake\bin\cmake.exe" --build VulkanMemoryAllocator-Hpp\cmake-build-debug --target Modules-Example -j 10
[0/1] Re-running CMake...
-- Building with Vulkan module at VulkanMemoryAllocator-Hpp/CppModule/Vulkan-Headers/include
-- Configuring done (0.1s)
-- Generating done (0.1s)
-- Build files have been written to: VulkanMemoryAllocator-Hpp/cmake-build-debug
[1/10] Generating CXX dyndep file CppModule\CMakeFiles\Vulkan-Hpp-Module.dir\CXX.dd
[2/8] Generating CXX dyndep file CppModule\CMakeFiles\VulkanMemoryAllocator-Hpp-Module.dir\CXX.dd
[3/6] Generating CXX dyndep file CppModule\CMakeFiles\Modules-Example.dir\CXX.dd
[4/6] Building CXX object CppModule\CMakeFiles\Modules-Example.dir\modules-example.cpp.obj
FAILED: CppModule/CMakeFiles/Modules-Example.dir/modules-example.cpp.obj 
C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1443~1.348\bin\Hostx64\x64\cl.exe  /nologo /TP -DVK_NO_PROTOTYPES=1 -IVulkanMemoryAllocator-Hpp\CppModule\Vulkan-Headers\include /DWIN32 /D_WINDOWS /EHsc /Ob0 /Od /RTC1 -std:c++20 -MDd -Zi /showIncludes @CppModule\CMakeFiles\Modules-Example.dir\modules-example.cpp.obj.modmap /FoCppModule\CMakeFiles\Modules-Example.dir\modules-example.cpp.obj /FdCppModule\CMakeFiles\Modules-Example.dir\ /FS -c VulkanMemoryAllocator-Hpp\CppModule\modules-example.cpp
VulkanMemoryAllocator-Hpp\CppModule\Vulkan-Headers\include\vulkan\vulkan.hpp(829): error C2027: use of undefined type 'vk::UniqueHandleTraits<Type,Dispatch>'
        with
        [
            Type=vma::Allocator,
            Dispatch=vma::Dispatcher
        ]
VulkanMemoryAllocator-Hpp\CppModule\Vulkan-Headers\include\vulkan\vulkan.hpp(826): note: see declaration of 'vk::UniqueHandleTraits<Type,Dispatch>'
        with
        [
            Type=vma::Allocator,
            Dispatch=vma::Dispatcher
        ]
VulkanMemoryAllocator-Hpp\CppModule\Vulkan-Headers\include\vulkan\vulkan.hpp(829): note: the template instantiation context (the oldest one first) is
VulkanMemoryAllocator-Hpp\CppModule\modules-example.cpp(45): note: see reference to class template instantiation 'vk::UniqueHandle<vma::Allocator,vma::Dispatcher>' being compiled
VulkanMemoryAllocator-Hpp\CppModule\Vulkan-Headers\include\vulkan\vulkan.hpp(829): error C2504: 'deleter': base class undefined
VulkanMemoryAllocator-Hpp\CppModule\Vulkan-Headers\include\vulkan\vulkan.hpp(832): error C2027: use of undefined type 'vk::UniqueHandleTraits<Type,Dispatch>'
        with
        [
            Type=vma::Allocator,
            Dispatch=vma::Dispatcher
        ]
VulkanMemoryAllocator-Hpp\CppModule\Vulkan-Headers\include\vulkan\vulkan.hpp(826): note: see declaration of 'vk::UniqueHandleTraits<Type,Dispatch>'
        with
        [
            Type=vma::Allocator,
            Dispatch=vma::Dispatcher
        ]
VulkanMemoryAllocator-Hpp\CppModule\Vulkan-Headers\include\vulkan\vulkan.hpp(832): error C2061: syntax error: identifier 'deleter'
VulkanMemoryAllocator-Hpp\CppModule\Vulkan-Headers\include\vulkan\vulkan.hpp(839): error C2061: syntax error: identifier 'Deleter'
VulkanMemoryAllocator-Hpp\CppModule\Vulkan-Headers\include\vulkan\vulkan.hpp(829): error C2027: use of undefined type 'vk::UniqueHandleTraits<Type,Dispatch>'
        with
        [
            Type=vma::Allocation,
            Dispatch=vma::Dispatcher
        ]
VulkanMemoryAllocator-Hpp\CppModule\Vulkan-Headers\include\vulkan\vulkan.hpp(826): note: see declaration of 'vk::UniqueHandleTraits<Type,Dispatch>'
        with
        [
            Type=vma::Allocation,
            Dispatch=vma::Dispatcher
        ]
VulkanMemoryAllocator-Hpp\CppModule\Vulkan-Headers\include\vulkan\vulkan.hpp(829): note: the template instantiation context (the oldest one first) is
VulkanMemoryAllocator-Hpp\CppModule\modules-example.cpp(47): note: see reference to class template instantiation 'std::pair<vk::UniqueHandle<vk::Buffer,vma::Dispatcher>,vk::UniqueHandle<vma::Allocation,vma::Dispatcher>>' being compiled
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\include\utility(473): note: see reference to class template instantiation 'vk::UniqueHandle<vma::Allocation,vma::Dispatcher>' being compiled
VulkanMemoryAllocator-Hpp\CppModule\Vulkan-Headers\include\vulkan\vulkan.hpp(832): error C2027: use of undefined type 'vk::UniqueHandleTraits<Type,Dispatch>'
        with
        [
            Type=vma::Allocation,
            Dispatch=vma::Dispatcher
        ]
VulkanMemoryAllocator-Hpp\CppModule\Vulkan-Headers\include\vulkan\vulkan.hpp(826): note: see declaration of 'vk::UniqueHandleTraits<Type,Dispatch>'
        with
        [
            Type=vma::Allocation,
            Dispatch=vma::Dispatcher
        ]
ninja: build stopped: subcommand failed.

CMake Options: -DVMA_BUILD_CXX_MODULE=ON -DVMA_BUILD_WITH_VULKAN_MODULE=ON -DVMA_BUILD_EXAMPLE=ON -DVMA_BUILD_MODULE_VULKAN_DYNAMIC=ON

I did add a small change to CppModule/CMakeLists.txt:

# find_package(Vulkan REQUIRED)
# find_package(VulkanMemoryAllocator CONFIG REQUIRED)
add_subdirectory(Vulkan-Headers)
set(Vulkan_INCLUDE_DIRS "${VULKAN_HEADERS_SOURCE_DIR}/include")
add_subdirectory(VulkanMemoryAllocator)

with symlinks to the git submodules.

OS: Windows 10 CMake: 3.31.5 Compiler: cl 19.43.34808 Generator: Ninja 1.12.0

The example builds and runs correctly when using clang on WSL: OS: Ubuntu 24.04.1 CMake: 3.31.5 Compiler: clang 19.1.1 Generator: Ninja 1.11.1

Qendolin avatar Feb 23 '25 21:02 Qendolin