i’m new to vulkan and trying to migrate from using function prototypes to VK_NO_PROTOTYPES and getting function pointers myself, need to note that before i started to refactor this everything was fine. i’m loading function pointers like this
//global variables
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr;
PFN_vkCreateInstance vkCreateInstance;
// function that is called before creating instance
vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_Vulkan_GetVkGetInstanceProcAddr();
vkCreateInstance = (PFN_vkCreateInstance)vkGetInstanceProcAddr(nullptr, "vkCreateInstance");
i’m creating sdl window before calling function pointers loading, so getting vkGetInstanceProcAddr pointer should end up fine.
i add them in header
but when i run that code i receive segmentation fault, so i tried to debug it a little. i found that the error occurs at the vkCreateInstance call, but vkCreateInstance pointer is not NULL, std::cout << (vkCreateInstance == NULL) << std::endl outputs 0, also print vkCreateInstance in gdb outputs $1 = (PFN_vkCreateInstance) 0x555561bde8 <vkCreateInstance> so vkCreateInstance is difenetely not NULL. but what else can cause this to happen if it was working before moving to VK_NO_PROTOTYPES? when i revert loading function pointers back to prototypes, everything starts to work again.
I had never used SDL2 before. So I can make some mistakes. But the Vulkan instance is successfully created. I also defined VK_NO_PROTOTYPES (in CMakeLists.txt).
About your code: I also use a shared library, and your code looks proper.