glfwInit function problem

Hi, guys.

I just learn GLFW in today.

I type the code of this page

Compile with

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.

#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");
		return -1;


	while (!glfwWindowShouldClose(window)) {

	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.

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.


To add to what dougbinks wrote, you can find information about retrieving glfw error messages here: perror will give you bogus messages.

1 Like

Thanks for @tombsar.
Found the problem.

It’s a wayland problem.