# GLFW / Vulkan init error

**URL:** <https://discourse.glfw.org/t/glfw-vulkan-init-error/752>\
**Category:** dev\
**Created:** [September 7, 2016, 10:02am UTC](https://discourse.glfw.org/t/glfw-vulkan-init-error/752 "2016-09-07T10:02:42Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![PadMad](https://avatars.discourse-cdn.com/v4/letter/p/d2c977/32.png) [@PadMad](https://discourse.glfw.org/u/PadMad)\
**Post date:** [September 7, 2016, 10:02am UTC](https://discourse.glfw.org/t/glfw-vulkan-init-error/752/1 "2016-09-07T10:02:42Z")

</div>

## g++ 5.4.0

## GNU Make 4.1

## GLFW 3.2.1

## Vulkan 1.0.8

## Ubuntu 16.04

hey,

I started a vulkan project and I use glfw for window / surface stuff. everything works great so far but when I try to create a surface via glfwCreateWindowSurface() I recieve the following error:

“Vulkan: Window surface creation extensions not found”

glfwGetRequiredInstanceExtensions() returns NULL, and number of extensions is 0. So I know thats the exact error.

this is the window creation code:

 ![](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/d25464dd8ac117f3e72b955990d993a1ed5a9b6a.png)

this is the vk instance creation code:

[instance creation](http://www.wp1105995.server-he.de/ins_create.png)

this is the surface creation call:

[surface call](http://www.wp1105995.server-he.de/surface_call.png)

All 3 functions are called in the order I mentioned them. So the strange thing is:

- glfwVulkanSupported() returns true!
- vkEnumerateInstanceExtensionProperties() gives an output of:  
VK\_KHR\_surface  
VK\_KHR\_xcb\_surface  
VK\_EXT\_debug\_report

So the extension I need is there (VK\_KHR\_surface)! I read the glfw reference of glfwGetRequiredInstanceExtensions() and it doesn’t offer any help really, 'cause everything that could fail, works… the only thing mentioned on the reference page is:

> If Vulkan is available but no set of extensions allowing window surface creation was found, this function returns NULL. You may still use Vulkan for off-screen rendering and compute work.

… okay… but I do want to render on-screen 😃  
So any help or guesses?

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [September 7, 2016, 10:33am UTC](https://discourse.glfw.org/t/glfw-vulkan-init-error/752/2 "2016-09-07T10:33:08Z")

</div>

Have you tried compiling and running the [vulkan.c test code](https://github.com/glfw/glfw/blob/master/tests/vulkan.c) for GLFW?

Note: It’s easier for us if you post code as text see [http://superuser.com/editing-help#code](http://superuser.com/editing-help#code) for an example of how to format code blocks.

---

<div class="post-metadata">

**Author:** ![PadMad](https://avatars.discourse-cdn.com/v4/letter/p/d2c977/32.png) [@PadMad](https://discourse.glfw.org/u/PadMad)\
**Post date:** [September 7, 2016, 11:06am UTC](https://discourse.glfw.org/t/glfw-vulkan-init-error/752/3 "2016-09-07T11:06:59Z")

</div>

hey,

thanks for that quick reply. I tried the example and recieved:

> glfwGetRequiredInstanceExtensions failed to find the platform surface extensions.

> Do you have a compatible Vulkan installable client driver (ICD) installed?  
> Please look at the Getting Started guide for additional information.

so is there anything I can do?

btw: I tried to post the code as a text but I didn’t find the code posting option. and c code is not really html.

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [September 7, 2016, 11:55am UTC](https://discourse.glfw.org/t/glfw-vulkan-init-error/752/4 "2016-09-07T11:55:42Z")

</div>

To post code just add four spaces at the start of each line.

Your installation of vulkan should come with a vulkaninfo command, can you run that and also detail which GPU and driver you’re using?

---

<div class="post-metadata">

**Author:** ![PadMad](https://avatars.discourse-cdn.com/v4/letter/p/d2c977/32.png) [@PadMad](https://discourse.glfw.org/u/PadMad)\
**Post date:** [September 7, 2016, 2:33pm UTC](https://discourse.glfw.org/t/glfw-vulkan-init-error/752/5 "2016-09-07T14:33:30Z")

</div>

hey,

I’m using a NVIDIA GEFORCE GT 710, driver: NVIDIA binary driver - version 364.16 from nvidia-364 (open source)  
I checked support before I started developing and my graphics card does support vulkan.

vulkaninfo output is quite long. I posted the SDK version before. But here is the whole output:  
[vulkan output](http://www.wp1105995.server-he.de/vulkaninfo.txt)

(too long for a forum post I guess)

I also tried to install a driver from that page first, which didn’t work on ubuntu really:  
[vulkan driver](https://developer.nvidia.com/vulkan-driver)  
But ubuntu offered recent (mentioned above) driver, which does support vulkan.

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [September 7, 2016, 3:57pm UTC](https://discourse.glfw.org/t/glfw-vulkan-init-error/752/6 "2016-09-07T15:57:25Z")

</div>

So it looks like Vulkan is correctly installed, but you only have the XCB surface and not an XLIB one.

The [required extension code on X11 uses this function](https://github.com/glfw/glfw/blob/e6a32db7b9553d835931673203602b9f657bd922/src/x11_window.c#L2321-L2338) which for VK\_KHR\_xcb\_surface needs an x11 xcb handle, [which is discovered here in the x11 handle](https://github.com/glfw/glfw/blob/e6a32db7b9553d835931673203602b9f657bd922/src/x11_init.c#L545-L550).

So my guess is that you’re missing [libX11-xcb.so](http://libX11-xcb.so) - if this isn’t the case it would have handy to put breakpoints in the above functions to see what’s happening.

---

<div class="post-metadata">

**Author:** ![PadMad](https://avatars.discourse-cdn.com/v4/letter/p/d2c977/32.png) [@PadMad](https://discourse.glfw.org/u/PadMad)\
**Post date:** [September 7, 2016, 6:28pm UTC](https://discourse.glfw.org/t/glfw-vulkan-init-error/752/7 "2016-09-07T18:28:17Z")

</div>

well libX11-xcb.so.1 is located in /usr/lib/x86\_64-linux-gnu. so I guess that one is available?  
I read in another forum that someone had the same error appearing. but it turned out that he called window creation after instance creation, which caused the error. but in my case it’s different. isn’t there any easy stupid mistake I could’ve done, before debugging glfw…?

---

<div class="post-metadata">

**Author:** ![PadMad](https://avatars.discourse-cdn.com/v4/letter/p/d2c977/32.png) [@PadMad](https://discourse.glfw.org/u/PadMad)\
**Post date:** [September 8, 2016, 8:01pm UTC](https://discourse.glfw.org/t/glfw-vulkan-init-error/752/8 "2016-09-08T20:01:26Z")

</div>

hey,

I tried to change both mentioned functions a bit to give an output, wether parts of them would be executed:

> char\*\* \_glfwPlatformGetRequiredInstanceExtensions(uint32\_t\* count)  
> {  
> char\*\* extensions;

> ```
> *count = 0;
> 
> ```

> ```
> if (!_glfw.vk.KHR_xcb_surface || !_glfw.x11.x11xcb.handle)
> {
> if (!_glfw.vk.KHR_xlib_surface)
> {return NULL;printf("couldn't load xlib\n");}
> }
> 
> ```

> ```
> extensions = calloc(2, sizeof(char*));
> extensions[0] = strdup("VK_KHR_surface");
> 
> ```

> ```
> if (_glfw.vk.KHR_xcb_surface && _glfw.x11.x11xcb.handle)
> {extensions[1] = strdup("VK_KHR_xcb_surface");printf("xcb\n");}
> else
> {extensions[1] = strdup("VK_KHR_xlib_surface");printf("xlib\n");}
> 
> ```

> ```
> *count = 2;
> return extensions;
> 
> ```
> 
> }

and

> \_glfw.x11.x11xcb.handle = dlopen(“libX11-xcb.so”, RTLD\_LAZY | RTLD\_GLOBAL);  
> if (\_glfw.x11.x11xcb.handle)  
> {  
> \_glfw.x11.x11xcb.XGetXCBConnection = (XGETXCBCONNECTION\_T)  
> dlsym(\_glfw.x11.x11xcb.handle, “XGetXCBConnection”);  
> }  
> else  
> {printf(“couldn’t open libX11-xcb.so\n”);}

ran cmake, make, installed it… but it didn’t seem to apply the changes… I didn’t recieve any output… so I’m really stucked in creating the window surface 😔

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [September 9, 2016, 8:31am UTC](https://discourse.glfw.org/t/glfw-vulkan-init-error/752/9 "2016-09-09T08:31:19Z")

</div>

It’s possible for your code to not call the printf’s but still fail to provide any required extensions.

I would either debug the code with a debugger, or add printf debugging on paths where you’re guaranteed to have the code execute such as at the start of the function or before every return.

---

<div class="post-metadata">

**Author:** ![maaex](https://avatars.discourse-cdn.com/v4/letter/m/8c91f0/32.png) [@maaex](https://discourse.glfw.org/u/maaex)\
**Post date:** [September 26, 2016, 8:15pm UTC](https://discourse.glfw.org/t/glfw-vulkan-init-error/752/10 "2016-09-26T20:15:58Z")

</div>

Snatching this thread a little… 🙂

I’m having a similar problem… glfwInit works fine, glfwGetRequiredInstanceExtensions() returns NULL, glfwVulkanSupported() returns false.

Still, the Vulkan samples (that come with the Vulkan SDK) works fine, and vulkaninfo seems to work fine too.

I’m thinking it has something to do with the vulkan loader?

On ubuntu 14.04, GTX840M, nvidia drivers 367.44, GLFW 3.2.1 (using cmake).  
I should say also im running the same project on windows through Visual Studio, which works FINE (on another PC though, with a GTX970).

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [September 27, 2016, 7:42am UTC](https://discourse.glfw.org/t/glfw-vulkan-init-error/752/11 "2016-09-27T07:42:05Z")

</div>

Have you been able to debug the two sections of code I linked to above to see what’s going on?

---

<div class="post-metadata">

**Author:** ![maaex](https://avatars.discourse-cdn.com/v4/letter/m/8c91f0/32.png) [@maaex](https://discourse.glfw.org/u/maaex)\
**Post date:** [September 27, 2016, 7:32pm UTC](https://discourse.glfw.org/t/glfw-vulkan-init-error/752/12 "2016-09-27T19:32:58Z")

</div>

I worked for a bit to get vulkan.c to run. It seems i wasn’t linking to libvulkan properly (i had thought glfw did that for me). Anyway, after getting vulkan.c to run, my project runs too 🙂 Thanks for the help!
