I have installed libgtk-3-dev
and wrote and compiled this code successfully(without errors I mean):
#include <gtk/gtk.h>
void destroy(void) {
gtk_main_quit();
}
int main (int argc, char** argv) {
GtkWidget* window;
GtkWidget* image;
gtk_init (&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
image = gtk_image_new_from_file(argv[1]);
g_signal_connect(G_OBJECT (window), "destroy",
G_CALLBACK (destroy), NULL);
gtk_container_add(GTK_CONTAINER (window), image);
gtk_widget_show_all(window);
gtk_main();
return 0;
}
But after trying to run the executable it says:
(process:5771): Gtk-WARNING **: Locale not supported by C library.
Using the fallback 'C' locale.
Failed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Could not connect: Connection refused
(img:5771): Gtk-WARNING **: cannot open display:
I should say I use Ubuntu-server 16/04 and installed xorg, xserver-xorg-video-fbdev, openbox
packages too. I have a gray blank screen with a black mouse and right-click menu after boot.
EDIT:
I used this command to connect to my board: ssh [email protected] -X
Then program worked and it opened the image by ./img 1.png
but in my laptop that I used for ssh! I liked to open the image in my board's LCD, not in my laptop!
Also it gives me this message in terminal:
(process:1909): Gtk-WARNING **: Locale not supported by C library.
Using the fallback 'C' locale.
SOLUTION:I attached a keyboard to my board and opened it's terminal(by right-click inside it's openbox window) and executed my program successfully and it showed my picture in the SPI LCD!
./test 1.png
it gives me that error!./test 1.png
works perfectly on my computer so your code works OK, there must be some problem with the operating system, probably related to the gray blank screen with a black mouse and right-click menu after boot. If the code is OK and there is an OS problem then this question is on topic. For example theFailed to connect to Mir: Failed to connect to server socket: No such file or directory
error may be because you executed a command as root that didn't need to be executed as root.startx
command inside/etc/rc.local