C プログラムでハッシュ テーブルを使用したいと考えています。
私はコードします:
...
#include <glib.h>
void main(int argc, char **argv)
{
GHashTable *g_hash_table;
...
g_hash_table = g_hash_table_new(g_int_hash, g_int_equal);
...
}
次にコンパイルします。
$ gcc -I/usr/include/glib-2.0
-I/usr/lib/i386-linux-gnu/glib-2.0/include
-lglib-2.0 -o test test.c
または同じコマンド:
$ gcc `pkg-config --cflags --libs glib-2.0` -o test test.c
とにかく結果は次のとおりです。
test.c: underfined reference to `g_int_equal`
test.c: underfined reference to `g_int_hash`
test.c: underfined reference to `g_hash_table_new`
collect2: ld returned 1 exit status
プログラムをコンパイルできないのはなぜですか? glib ライブラリのインクルードを間違えていますか?