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 m@192.168.1.7 -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!

  • @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! – user145959 Nov 2 '17 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 Nov 2 '17 at 9:29
  • @karel: here I said how did I run my display! I think the problem is here: unix.stackexchange.com/questions/401884/… – user145959 Nov 2 '17 at 9:34
  • I used startx command inside /etc/rc.local – user145959 Nov 2 '17 at 9:37
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!

0

The error you received is:

(process:1909): Gtk-WARNING **: Locale not supported by C library.   
    Using the fallback 'C' locale.   

The img executable is displaying the image in fallback mode on your laptop instead of displaying it on the LCD monitor which is connected to your board. The LCD screen that is connected to your board is getting output in Openbox:

enter image description here

gcc-5 is the GNU C Compiler which is installed on my Ubuntu 16.04 which I used to compile your code.

gcc-5 `pkg-config --cflags gtk+-3.0` -o img img.c `pkg-config --libs gtk+-3.0`  
  • I compiled the code with your command again, without errors, but GTK WARNING exists yet! and image shown in my laptop again – user145959 Nov 2 '17 at 14:51
  • Maybe I must install something like xdm ? I couldn't understand what is difference between X11/Xorg/Xserver/X window manger – user145959 Nov 2 '17 at 15:51
  • xdm is a graphical login screen for xorg that you don't need to install. – karel Nov 2 '17 at 15:53
  • I found that this gray screen is openbox . in right-click menu there is a EXIT option that when I clicked it showed a message says Do you want to exit from openbox and I clicked yes, then my screen locked and my mouse doesn't work. – user145959 Nov 2 '17 at 16:24
  • 1
    This is what I have in my screen: uupload.ir/files/07hu_photo_2017-11-02_20-13-18.jpg – user145959 Nov 2 '17 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.