# glfwInit function problem

**URL:** <https://discourse.glfw.org/t/glfwinit-function-problem/928>\
**Category:** support\
**Created:** [July 3, 2017, 9:25am UTC](https://discourse.glfw.org/t/glfwinit-function-problem/928 "2017-07-03T09:25:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ikyp](https://avatars.discourse-cdn.com/v4/letter/i/b77776/32.png) [@ikyp](https://discourse.glfw.org/u/ikyp)\
**Post date:** [July 3, 2017, 9:25am UTC](https://discourse.glfw.org/t/glfwinit-function-problem/928/1 "2017-07-03T09:25:51Z")

</div>

Hi, guys.

I just learn GLFW in today.

I type the code of this page [http://www.glfw.org/documentation.html](http://www.glfw.org/documentation.html).

Compile with

```auto
gcc -Wall `pkg-config --cflags glfw3 glu` `pkg-config --static --libs glfw3 glu`

```

It’s done. And i run program. show nothing.

So, i modify the code to show error message.

```auto
#include <GLFW/glfw3.h>
#include <stdio.h>

int main(void)
{
	GLFWwindow *window;

	if (!glfwInit()) {
		perror("glfwInit Error");
		return -1;
	}

	window = glfwCreateWindow(640, 400, "Hello GLFW", NULL, NULL);
	if (!window) {
		perror("glfwCreatewindow Error");
		glfwTerminate();
		return -1;
	}

	glfwMakeContextCurrent(window);

	while (!glfwWindowShouldClose(window)) {
		glClear(GL_COLOR_BUFFER_BIT);
		glfwSwapBuffers(window);
		glfwPollEvents();
	}

	glfwTerminate();
	return 0;
}

```

Recompile it and run it ,show the fllowing message:

`glfwInit Error: No such file or directory`

In this problem, how can i solve?

I don’t have any idea.

The `GLFW` path and `GLU` path doesn’t have problem.

---

<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:** [July 3, 2017, 10:03am UTC](https://discourse.glfw.org/t/glfwinit-function-problem/928/2 "2017-07-03T10:03:01Z")

</div>

Note that `perror` isn’t a suitable error message caller here as it is for standard library function errors, not glfw ones. You can either just use `printf` to standard output or use `fprintf` with stderr.

As to why glfwInit is failing, it would be helpful to know what OS you are on, which version of glfw you installed and how you installed it (from source etc.), and whether you can run other OpenGL programs on the machine.

---

<div class="post-metadata">

**Author:** ![tombsar](https://avatars.discourse-cdn.com/v4/letter/t/db5fbb/32.png) [@tombsar](https://discourse.glfw.org/u/tombsar)\
**Post date:** [July 5, 2017, 12:58pm UTC](https://discourse.glfw.org/t/glfwinit-function-problem/928/3 "2017-07-05T12:58:28Z")

</div>

To add to what dougbinks wrote, you can find information about retrieving glfw error messages here: [http://www.glfw.org/docs/latest/quick.html#quick\_capture\_error](http://www.glfw.org/docs/latest/quick.html#quick_capture_error) `perror` will give you bogus messages.

---

<div class="post-metadata">

**Author:** ![ikyp](https://avatars.discourse-cdn.com/v4/letter/i/b77776/32.png) [@ikyp](https://discourse.glfw.org/u/ikyp)\
**Post date:** [July 8, 2017, 5:18pm UTC](https://discourse.glfw.org/t/glfwinit-function-problem/928/4 "2017-07-08T17:18:42Z")

</div>

**Thanks for** `@tombsar`.  
Found the problem.

It’s a `wayland` problem.
