While running a GTK+ based C program under Cygwin, the following runtime error is observed,
Gtk-WARNING **: cannot open display:
DISPLAY=":0"
export DISPLAY
if [[ -z "$DISPLAY" ]]
then
DISPLAY=":0"
export DISPLAY
fi
#include <stdlib.h>
// introduce the environment variable
// DISPLAY, if not present
if (setenv ("DISPLAY", ":0", 0) == -1)
error ("setenv");
This will obviate the requirement of setting the environment variable and is particularly helpful if you wish to run the program directly under Windows.