Glib – référence indéfinie à quelque chose de glib?

J’ai un problème avec mon programme S. J’ai besoin de le comstackr avec cette commande:

gcc -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -lglib-2.0 \ -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wall -Wextra -g -std=c99 -lm *.c \ -o generator1_1 

J’ai beaucoup de messages d’erreur comme celui-ci:

 /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/main.c:153: undefined reference to `g_hash_table_lookup' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/main.c:171: undefined reference to `g_hash_table_insert' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/main.c:172: undefined reference to `g_array_append_vals' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/main.c:179: undefined reference to `g_array_append_vals' /tmp/ccVqEbsM.o: In function `main': /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/main.c:238: undefined reference to `g_hash_table_new_full' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/main.c:239: undefined reference to `g_hash_table_new_full' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/main.c:263: undefined reference to `g_hash_table_destroy' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/main.c:264: undefined reference to `g_hash_table_destroy' /tmp/cc2UG2Wy.o: In function `fillVFile': /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/reader.c:47: undefined reference to `g_strdup' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/reader.c:51: undefined reference to `g_ptr_array_add' /tmp/cctOiTOl.o: In function `calculRegles': /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/regles.c:23: undefined reference to `g_hash_table_get_values' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/regles.c:48: undefined reference to `g_list_length' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/regles.c:57: undefined reference to `g_list_sort' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/regles.c:82: undefined reference to `g_hash_table_new' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/regles.c:85: undefined reference to `g_array_new' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/regles.c:110: undefined reference to `g_hash_table_lookup' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/regles.c:116: undefined reference to `g_hash_table_lookup' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/regles.c:121: undefined reference to `log2' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/regles.c:125: undefined reference to `g_array_append_vals' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/regles.c:128: undefined reference to `g_hash_table_insert' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/regles.c:139: undefined reference to `g_array_sort' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/regles.c:167: undefined reference to `g_hash_table_lookup' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/regles.c:176: undefined reference to `g_hash_table_lookup' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/regles.c:198: undefined reference to `g_hash_table_destroy' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/regles.c:199: undefined reference to `g_array_free' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/regles.c:205: undefined reference to `g_list_free' /tmp/cczRKfT8.o: In function `cstSequence1': /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/sequence1.c:19: undefined reference to `g_array_new' /tmp/cczRKfT8.o: In function `dstSequence1': /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/sequence1.c:26: undefined reference to `g_array_free' /tmp/cczRKfT8.o: In function `hashSeq1Fct': /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/sequence1.c:97: undefined reference to `g_str_hash' /tmp/cczRKfT8.o: In function `eqSeq1Fct': /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/sequence1.c:113: undefined reference to `g_str_equal' /tmp/cc7ZNuaW.o: In function `cstSequence2': /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/sequence2.c:22: undefined reference to `g_array_new' /tmp/cc7ZNuaW.o: In function `dstSequence2': /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/sequence2.c:29: undefined reference to `g_array_free' /tmp/cc7ZNuaW.o: In function `hashSeq2Fct': /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/sequence2.c:131: undefined reference to `g_str_hash' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/sequence2.c:132: undefined reference to `g_str_hash' /tmp/cc7ZNuaW.o: In function `eqSeq2Fct': /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/sequence2.c:152: undefined reference to `g_str_equal' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/sequence2.c:153: undefined reference to `g_str_equal' /tmp/ccY2cdEJ.o: In function `foncteurRetireDoublonsSeq1': /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/utils.c:29: undefined reference to `g_array_remove_index' /tmp/ccY2cdEJ.o: In function `foncteurRetireDoublonsSeq2': /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/utils.c:52: undefined reference to `g_array_remove_index' /tmp/ccY2cdEJ.o: In function `retireDoublonsLignesSeq1': /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/utils.c:66: undefined reference to `g_hash_table_get_values' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/utils.c:68: undefined reference to `g_list_foreach' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/utils.c:70: undefined reference to `g_list_free' /tmp/ccY2cdEJ.o: In function `retireDoublonsLignesSeq2': /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/utils.c:75: undefined reference to `g_hash_table_get_values' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/utils.c:77: undefined reference to `g_list_foreach' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/utils.c:79: undefined reference to `g_list_free' /tmp/cc8GGinx.o: In function `cstVFile': /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/vfile.c:15: undefined reference to `g_ptr_array_sized_new' /tmp/cc8GGinx.o: In function `dstVFile': /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/vfile.c:26: undefined reference to `g_free' /home/cyrine/Bureau/Seq_GLib2_1_1_Triche/vfile.c:29: undefined reference to `g_ptr_array_free' collect2: ld returned 1 exit status make: *** [all] Error 1 

Je travaille avec Ubuntu 12.04. Est-ce que quelqu’un a une idée?

Incluez les bibliothèques, spécifiées par -l , après les fichiers ‘object’ (ou les fichiers source lorsque vous comstackz la source et créez un lien en une fois).

Tu as:

 gcc -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include \ -lglib-2.0 \ -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wall -Wextra -g -std=c99 \ -lm *.c -o generator1_1 

Vous avez besoin:

 gcc -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include \ -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wall -Wextra -g -std=c99 \ *.c -lglib-2.0 -lm -o generator1_1 

Il peut y avoir quelques systèmes où vous pouvez spécifier des bibliothèques à des positions arbitraires dans la ligne de commande de liaison, mais «bibliothèques après fichiers objects» a toujours fonctionné sur tous les systèmes que j’ai rencontrés.