# glfwInit unintentionally using wayland

**URL:** https://discourse.glfw.org/t/glfwinit-unintentionally-using-wayland/1454
**Category:** support
**Created:** [December 15, 2019, 5:06pm UTC](https://discourse.glfw.org/t/glfwinit-unintentionally-using-wayland/1454 "2019-12-15T17:06:22Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Zeepaardje98](https://avatars.discourse-cdn.com/v4/letter/z/22d042/32.png) [@Zeepaardje98](https://discourse.glfw.org/u/Zeepaardje98)
#### Post date: [December 15, 2019, 5:06pm UTC](https://discourse.glfw.org/t/glfwinit-unintentionally-using-wayland/1454/1 "2019-12-15T17:06:22Z")

</div>

So I’m trying to get GLFW to work with the simplest code possible:

> #include   
> #include \<GLFW/glfw3.h\>
> 
> using namespace std;
> 
> void error\_callback(int error, const char\* description)  
> {  
> fprintf(stderr, “Error: ‘%s’\n”, description);  
> }
> 
> int main() {  
> glfwSetErrorCallback(error\_callback);
> 
> ```
> if (!glfwInit()) {
> std::cout << "Error: glfwInit" << std::endl;
> }
> else {
> std::cout << "Succes: glfwInit" << std::endl;
> }
> return 0;
> 
> ```
> 
> }

Sadly, running this code returns the following error:

> Error: ‘Wayland: Failed to connect to display’

This seems weird, because I am not using wayland.

> echo $XDG\_SESSION\_TYPE

gives me x11, so i would expect glfwInit() to use that, instead of wayland. Does anyone know how to fix this problem? I am using ubuntu 18.04.

---

<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: [December 15, 2019, 9:08pm UTC](https://discourse.glfw.org/t/glfwinit-unintentionally-using-wayland/1454/2 "2019-12-15T21:08:27Z")

</div>

Hi Zeepaardje98 welcome to the forum!

How did you get/compilethe GLFW library? It sounds like it might be compiled with Wayland support but not X11.

---

<div class="post-metadata">

### Author: ![Zeepaardje98](https://avatars.discourse-cdn.com/v4/letter/z/22d042/32.png) [@Zeepaardje98](https://discourse.glfw.org/u/Zeepaardje98)
#### Post date: [December 16, 2019, 8:33pm UTC](https://discourse.glfw.org/t/glfwinit-unintentionally-using-wayland/1454/3 "2019-12-16T20:33:13Z")

</div>

I think you’re right. I’m not sure how I compiled it with wayland support, but remaking the files seem to have fixed the problem. Thanks for your time!
