Sunday, 18 August 2013

"Failed to open X display" when trying to run project from within Eclipse

"Failed to open X display" when trying to run project from within Eclipse

I have a simple OpenGL/GLFW test program in Eclipse
#include <iostream>
#include <string>
#include <GL/glew.h>
#define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.h>
void errorCallback(int error, const char *description)
{
std::cerr << description << " (GLFW error " << error << ")" << std::endl;
}
int main(int argc, char **argv)
{
int returnValue = 0;
try {
// Initialise GLFW.
glfwSetErrorCallback(errorCallback);
if(!glfwInit()) throw std::string("Could not initialise GLFW");
/* ...do everything else... */
} catch(std::string const &str) {
std::cerr << "Error: " << str << std::endl;
returnValue = 1;
}
return returnValue
}
However, running it causes the following to come up in the console: X11:
Failed to open X display (GLFW error 65542) Error: Could not initialise
GLFW
i.e. it fails during glfwInit() (I commented out all the code just to make
sure it doesn't actually happen during window creation or something).
However, navigating to the build directory (using my file manager, not
Eclipse, that is) and manually launching from there works just fine.
Anyone know what the problem could be?

No comments:

Post a Comment