lordankou | voila une réponse plus clair à mon prb :
Voilà j'ai un gros problème de compilation gtk sous linux.
[kerdreux@localhost visualisation]$ pkg-config --modversion gtk+
2.2.4
[kerdreux@localhost visualisation]$ pkg-config --cflags --libs gtk+
-I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/X11R6/include -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -Wl,--export-dynamic -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangoxft-1.0 -lpangox-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0
ors quand je lance mon main.cpp avec la commande suivante :
[kerdreux@localhost visualisation]$ gcc -Wall -g main.cpp -o main 'gtk-config --cflags –libs'
j'obtiens le résultat suivant :
gcc: gtk-config --cflags --libs: No such file or directory
main.cpp:10:21: gtk/gtk.h: No such file or directory
main.cpp:19: error: `GtkWidget' was not declared in this scope
...
en modifiant la compile avec :
[kerdreux@localhost visualisation]$ cat compile
gcc -Wall -g main.cpp -o main -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/X11R6/include -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -Wl,--export-dynamic -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangoxft-1.0 -lpangox-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0
[kerdreux@localhost visualisation]$
j'obtiens : [kerdreux@localhost visualisation]$ compile
/home/kerdreux/tmp/ccaigFbW.o(.eh_frame+0x11): In function `main':
/mnt/win_d2/visualisation/main.cpp:35: undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
[kerdreux@localhost visualisation]$
par contre en modifiant tous les appels aux fonctions gtk (je les mes en commentaire) il me compile correctement le programme.
Voici le code source :
Code :
- /********************
- * Implementation
- ********************/
- /**********
- LIBRAIRIE
- **********/
- #include <stdlib.h>
- #include <gtk/gtk.h>
- #include "texte.h" // fichier contenant les expressions
- /**********************
- EN TETE DES FONCTIONS
- **********************/
- // procedure de destruction d'une fenetre
- void OnDestroy(GtkWidget *Fenetre, gpointer Data);
- // procedure d'initialisation d'une fenetre
- void InitWindows(GtkWidget *Fenetre);
- /************************
- PROGAMMA PRINCIPALE
- ************************/
- int main(int argc, char **argv)
- {
- // creation du widget
- GtkWidget *Console;
- // init du GTK
- gtk_init(&argc, &argv);
- // init du widget
- Console = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- // connecxion du signal destroy
- //g_signal_connect(G_OBJECT(Consol, "destroy", G_CALLBACK(OnDestroy),NULL);
- // affichage de la fenetre
- gtk_widget_show(Console);
- // boucle evenementielle
- gtk_main();
- // fin du prg
- return EXIT_SUCCESS;
- }
- /********************
- CORPS DES FONCTIONS
- ********************/
- // procedure de destruction d'une fenetre
- void OnDestroy(GtkWidget *Fenetre, gpointer Data)
- {
- // arrêt de la boucle evenementielle
- gtk_main_quit();
- }
- // procedure d'initialisation d'une fenetre
- void InitWindows(GtkWidget *Fenetre)
- {
- // position de la fenetre passé en paramètre : aléatoire
- gtk_window_set_position(GTK_WINDOW(Fenetre),GTK_WIN_POS_NONE) ;
- // Titre de la fenetre à partir du fichier
- gtk_window_set_title(GTK_WINDOW(Fenetre),NameWindows);
- // taille de la fenetre
- gtk_window_set_default_size(GTK_WINDOW(Fenetre),LargeurWindow,HauteurWindow);
- }
|
|