Bonjour,

Débutant en informatique, je cherche à intégrer une image avec GTK.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void afficher_image(GtkWidget *pButton3, gpointer data)
{
    GtkWidget *pWindow_image;
    GtkWidget * pImage;
    GtkWidget * pHBox;
 
    pWindow_image=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_default_size(GTK_WINDOW(pWindow_image), 320, 200);
    gtk_window_set_title(GTK_WINDOW(pWindow_image), "Image");
    g_signal_connect(G_OBJECT(pWindow_image), "destroy", G_CALLBACK(gtk_main_quit), NULL);
 
    pHBox = gtk_hbox_new(FALSE, 0);
    gtk_container_add(GTK_CONTAINER(pWindow_image), pHBox);
 
    /* Chargement d'une image a partir d'un fichier */
    pImage = gtk_image_new_from_file("c:\\img.png");
    gtk_box_pack_start(GTK_BOX(pHBox), pImage, FALSE, FALSE, 5);
 
    gtk_widget_show_all(pWindow_image);
}
Lorsque je tente de compiler, il est noté "undefined reference to 'gtk_image_New_from_file'

L'erreur vient au niveau de pImage. J'ai essayé de nommé différemment le chemin d'accès au fichier (en notant "c:/img.png" mais sans résultat. Les librairies initialisées sont
#include <stdlib.h>
#include <gtk/gtk.h>
#include <string.h>
#include <glib.h>
#include <glib/gprintf.h>

Quelqu'un aurait-il une solution?

--
Jean-François