3

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!

4
  • @karel: Thanks Karel, but I tried the GTK official example and it didn't work too, and gave me the same error! I must emphasis that my code compiles without error too but when I try ./test 1.png it gives me that error! Commented Nov 2, 2017 at 9:24
  • ./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 the Failed 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.
    – karel
    Commented Nov 2, 2017 at 9:29
  • @karel: here I said how did I run my display! I think the problem is here: unix.stackexchange.com/questions/401884/… Commented Nov 2, 2017 at 9:34
  • I used startx command inside /etc/rc.local Commented Nov 2, 2017 at 9:37

1 Answer 1

1

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!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .