glfwInit function problem


#1

Hi, guys.

I just learn GLFW in today.

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

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");
		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.


#2

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.


#3

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 perror will give you bogus messages.


#4

Thanks for @tombsar.
Found the problem.

It’s a wayland problem.