Vulkan code ALWAYS crashes with the same error

I’ve recently downloaded the Vulkan SDK and created a new C Project in Eclipse, to test out some boilerplate Vulkan code. I’ve definitely linked the vulkan-1.lib library and included all required header files in the SDK properly (In fact I’ve quadruple checked the build settings), and my graphics drivers definitely support Vulkan, as both vkcube.exe and vkcubepp.exe both run properly without any qualms. My code also compiles with 0 errors at all, yet whenever I try to execute it, it always crashes with this error:

There’s absolutely nothing on google searches that is related to my problem, could anyone help me with this?

In case it’s important, the IDE is Eclipse CDT, and this is the test code:

/*
 ============================================================================
 Name        : VulkanTest.c
 Author      : TheShermanTanker
 Version     :
 Copyright   : None
 Description : Hello World in C, Ansi-style
 ============================================================================
 */

#include <stdio.h>
#include <stdlib.h>

#include "vulkan/vulkan.h"

int main(void) {
	puts("Hello World"); /* prints Hello World */

	VkResult status;
	VkInstance instance;
	VkApplicationInfo applicationInfo = {};
	VkInstanceCreateInfo instanceInfo = {};

	applicationInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
	applicationInfo.pNext = NULL;
	applicationInfo.pApplicationName = "Vulkan Test";
    applicationInfo.applicationVersion = VK_MAKE_VERSION(1, 2, 0);
    applicationInfo.pEngineName = "Native Engine";
    applicationInfo.engineVersion = VK_MAKE_VERSION(1, 2, 0);
    applicationInfo.apiVersion = VK_API_VERSION_1_2;

    instanceInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
    instanceInfo.pApplicationInfo = &applicationInfo;
    instanceInfo.enabledLayerCount = 0;
    instanceInfo.enabledExtensionCount = 0;
    instanceInfo.flags = 0;
    status = vkCreateInstance(&instanceInfo, NULL, &instance);

    if(status != VK_SUCCESS) {
    	puts("\nFailed to initialise Vulkan");
    	return status;
    }

	return EXIT_SUCCESS;
}

P.S.: By the way, when I say crash, it crashes even before the Hello World message can be displayed to console. Removing vkCreateInstance immediately resolves the crash

Your code is working fine (just tested it). Can it be that you have configured your project to be a dynamic library (.dll) instead of an application (.exe)?

Just checked, I configured it correctly, it is an exe:

Double clicking the exe gives the same error too :frowning:

I am not familiar with Eclipse, but it has to do with the Eclipse project settings since your code runs in a project that is properly configured as a Windows console application. Double check your application configuration – maybe follow a tutorial to create an application properly from scratch. Good luck!

I would agree it is related to your project settings. Given that it complains about not finding the expected entry point, have you configured it to build a windowed (as opposed to a console) application? In which case your entry point should be WinMain or wWinMain, see e.g. https://docs.microsoft.com/en-us/windows/win32/learnwin32/winmain–the-application-entry-point for details.

At least it crashes with the same error. Wait until your projects crash for different reasons every time like I had it once :smiley:

1 Like