c++linker-errorsvulkanunresolved-external

Unresolved external symbol when using vkSetDebugUtilsObjectNameEXT()?


Well i have changed some old function and after closing the Validationlayers tell me that i dont delete/clear up recources and now trying to set up DebugUtilsObjectName function to make it easier to find the recource;

void DebugUtilsObjectName(uint64_t objectHandle, const char* pObjectName, VkDevice device, VkObjectType objectType) {
    VkDebugUtilsObjectNameInfoEXT DebugUtilsObjectNameInfo{};
    DebugUtilsObjectNameInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
    DebugUtilsObjectNameInfo.pNext = nullptr;
    DebugUtilsObjectNameInfo.objectType = objectType;
    DebugUtilsObjectNameInfo.objectHandle = objectHandle;
    DebugUtilsObjectNameInfo.pObjectName = pObjectName;

    vkSetDebugUtilsObjectNameEXT(device, &DebugUtilsObjectNameInfo);
}

and i end up with:

Linker error i end up with:

I tried reading through the doc of it and couldn't find anything outstanding that might help me


Solution

  • Vulkan headers only expose prototypes for extension functions, provided you did not add VK_NO_PROTOTYPES. It does not provide actual functions. This is to allow you to override things like VK_DEFINE_NON_DISPATCHABLE_HANDLE or VK_USE_64_BIT_PTR_DEFINES (in which case you also need to load core functions manually).

    You must load extension function pointers manually using vkGetInstanceProcAddr for instance function pointers or vkGetDeviceProcAddr for device function pointers (see this post for the differences):

    auto* pfn = reinterpret_cast<PFN_vkSetDebugUtilsObjectNameEXT>(vkGetInstanceProcAddr(instance, "vkSetDebugUtilsObjectNameEXT"));
    

    You may also extract that stuff from vulkan.hpp which has a list of symbols to load or consider VOLK (I think ?).