PacktPublishing / Vulkan-Cookbook

Code repository for Vulkan Cookbook by Packt
MIT License
816 stars 109 forks source link

error: cannot bind non-const lvalue reference of type ‘VulkanCookbook::VkDestroyer<VulkanCookbook::VkSemaphoreWrapper>&’ to an rvalue of type ‘VulkanCookbook::VkDestroyer<VulkanCookbook::VkSemaphoreWrapper>’ #10

Closed aquiseb closed 5 years ago

aquiseb commented 5 years ago

I'm able to cmake . and make until this error occurs.

error: cannot bind non-const lvalue reference of type ‘VulkanCookbook::VkDestroyer&’ to an rvalue of type ‘VulkanCookbook::VkDestroyer

Any idea what's going on? I have created one additional file which is the following, and includes all my imports from the sdk. So these are the only ones I have. Here's my_sdk_headers.h

#ifndef MY_SDK_HEADERS
#define MY_SDK_HEADERS

#include "vulkan.h"
#include "vk_platform.h"
#include "vulkan_core.h"
#include "vulkan_xcb.h"

#endif // MY_SDK_HEADERS

And the error

[ 54%] Building CXX object CMakeFiles/13-Enabling_Alpha_Blending.dir/Samples/Common_Files/CookbookSampleFramework.cpp.o
In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/c++allocator.h:33:0,
                 from /usr/include/c++/7/bits/allocator.h:46,
                 from /usr/include/c++/7/string:41,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from /home/mies/vulkanpath/Vulkan-Cookbook/Library/Common Files/Common.h:41,
                 from /home/mies/vulkanpath/Vulkan-Cookbook/Library/Source Files/01 Instance and Devices/03 Connecting with a Vulkan Loader library.h:32,
                 from /home/mies/vulkanpath/Vulkan-Cookbook/Library/Common Files/AllHeaders.h:36,
                 from /home/mies/vulkanpath/Vulkan-Cookbook/Samples/Common Files/CookbookSampleFramework.h:36,
                 from /home/mies/vulkanpath/Vulkan-Cookbook/Samples/Common Files/CookbookSampleFramework.cpp:32:
/usr/include/c++/7/ext/new_allocator.h: In instantiation of ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = VulkanCookbook::FrameResources; _Args = {VkCommandBuffer_T*&, VulkanCookbook::VkDestroyer<VulkanCookbook::VkSemaphoreWrapper>, VulkanCookbook::VkDestroyer<VulkanCookbook::VkSemaphoreWrapper>, VulkanCookbook::VkDestroyer<VulkanCookbook::VkFenceWrapper>, VulkanCookbook::VkDestroyer<VulkanCookbook::VkImageViewWrapper>, VulkanCookbook::VkDestroyer<VulkanCookbook::VkFramebufferWrapper>}; _Tp = VulkanCookbook::FrameResources]’:
/usr/include/c++/7/bits/alloc_traits.h:475:4:   required from ‘static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = VulkanCookbook::FrameResources; _Args = {VkCommandBuffer_T*&, VulkanCookbook::VkDestroyer<VulkanCookbook::VkSemaphoreWrapper>, VulkanCookbook::VkDestroyer<VulkanCookbook::VkSemaphoreWrapper>, VulkanCookbook::VkDestroyer<VulkanCookbook::VkFenceWrapper>, VulkanCookbook::VkDestroyer<VulkanCookbook::VkImageViewWrapper>, VulkanCookbook::VkDestroyer<VulkanCookbook::VkFramebufferWrapper>}; _Tp = VulkanCookbook::FrameResources; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<VulkanCookbook::FrameResources>]’
/usr/include/c++/7/bits/vector.tcc:100:30:   required from ‘void std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {VkCommandBuffer_T*&, VulkanCookbook::VkDestroyer<VulkanCookbook::VkSemaphoreWrapper>, VulkanCookbook::VkDestroyer<VulkanCookbook::VkSemaphoreWrapper>, VulkanCookbook::VkDestroyer<VulkanCookbook::VkFenceWrapper>, VulkanCookbook::VkDestroyer<VulkanCookbook::VkImageViewWrapper>, VulkanCookbook::VkDestroyer<VulkanCookbook::VkFramebufferWrapper>}; _Tp = VulkanCookbook::FrameResources; _Alloc = std::allocator<VulkanCookbook::FrameResources>]’
/home/mies/vulkanpath/Vulkan-Cookbook/Samples/Common Files/CookbookSampleFramework.cpp:245:7:   required from here
/usr/include/c++/7/ext/new_allocator.h:136:4: error: cannot bind non-const lvalue reference of type ‘VulkanCookbook::VkDestroyer<VulkanCookbook::VkSemaphoreWrapper>&’ to an rvalue of type ‘VulkanCookbook::VkDestroyer<VulkanCookbook::VkSemaphoreWrapper>’
  { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/mies/vulkanpath/Vulkan-Cookbook/Library/Common Files/AllHeaders.h:195:0,
                 from /home/mies/vulkanpath/Vulkan-Cookbook/Samples/Common Files/CookbookSampleFramework.h:36,
                 from /home/mies/vulkanpath/Vulkan-Cookbook/Samples/Common Files/CookbookSampleFramework.cpp:32:
/home/mies/vulkanpath/Vulkan-Cookbook/Library/Source Files/09 Command Recording and Drawing/19 Increasing the performance through increasing the number of separately rendered frames.h:45:5: note:   initializing argument 2 of ‘VulkanCookbook::FrameResources::FrameResources(VkCommandBuffer_T*&, VulkanCookbook::VkDestroyer<VulkanCookbook::VkSemaphoreWrapper>&, VulkanCookbook::VkDestroyer<VulkanCookbook::VkSemaphoreWrapper>&, VulkanCookbook::VkDestroyer<VulkanCookbook::VkFenceWrapper>&, VulkanCookbook::VkDestroyer<VulkanCookbook::VkImageViewWrapper>&, VulkanCookbook::VkDestroyer<VulkanCookbook::VkFramebufferWrapper>&)’
     FrameResources( VkCommandBuffer            & command_buffer,
     ^~~~~~~~~~~~~~
CMakeFiles/13-Enabling_Alpha_Blending.dir/build.make:86: recipe for target 'CMakeFiles/13-Enabling_Alpha_Blending.dir/Samples/Common_Files/CookbookSampleFramework.cpp.o' failed
make[2]: *** [CMakeFiles/13-Enabling_Alpha_Blending.dir/Samples/Common_Files/CookbookSampleFramework.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/13-Enabling_Alpha_Blending.dir/all' failed
make[1]: *** [CMakeFiles/13-Enabling_Alpha_Blending.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
Ekzuzy commented 5 years ago

Does the project compile without any modifications (without the added file)? If problem exists also on clean repository, what platform do You compile the project on - what OS and what version of the compilator do You use?

lunochod commented 5 years ago

Same issue with clean repo using Ubuntu 18.04 LTS

Technipion commented 5 years ago

I had the same problem but was able to fix it. But compiling the repo as-is under Ubuntu doesn't really make sense since there is no WindowFramework implemented for linux yet. However I also added that in my personal fork, so it does now generate executable files under Ubuntu 18.04. At some point these changes might be implemented in the official repo, but there are still some bugs when compiling on linux.