2012-04-20 89 views
0

我試圖從谷歌代碼編譯簡單的gst player。我有固定和安裝缺少的庫現在我m到處鏈接錯誤Gtk和gstreamer鏈接器錯誤

[email protected]:~/work/gst-player-0.0.0$ make 
gcc -ggdb -Wall -W -Wformat-nonliteral -Wcast-align -Wpointer-arith -Wbad-function-cast -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Winline -Wundef -Wnested-externs -Wcast-qual -Wshadow -Wwrite-strings -Wno-unused-parameter -Wfloat-equal -pedantic -ansi -std=c99 `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0` `pkg-config --cflags gstreamer-0.10` `pkg-config --libs gstreamer-0.10` -lgstinterfaces-0.10 ui.c gst-backend.c -o gst-player 
In file included from /usr/include/gtk-2.0/gtk/gtk.h:236:0, 
       from ui.c:19: 
/usr/include/gtk-2.0/gtk/gtkitemfactory.h:47:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes] 
ui.c: In function ‘toggle_fullscreen’: 
ui.c:60:9: warning: passing argument 1 of ‘gtk_window_unfullscreen’ from incompatible pointer type [enabled by default] 
/usr/include/gtk-2.0/gtk/gtkwindow.h:340:10: note: expected ‘struct GtkWindow *’ but argument is of type ‘struct GtkWidget *’ 
ui.c:65:9: warning: passing argument 1 of ‘gtk_window_fullscreen’ from incompatible pointer type [enabled by default] 
/usr/include/gtk-2.0/gtk/gtkwindow.h:339:10: note: expected ‘struct GtkWindow *’ but argument is of type ‘struct GtkWidget *’ 
gst-backend.c: In function ‘backend_query_position’: 
gst-backend.c:164:5: warning: pointer targets in passing argument 3 of ‘gst_element_query_position’ differ in signedness [-Wpointer-sign] 
/usr/include/gstreamer-0.10/gst/gstutils.h:1047:25: note: expected ‘gint64 *’ but argument is of type ‘guint64 *’ 
gst-backend.c: In function ‘backend_query_duration’: 
gst-backend.c:177:5: warning: pointer targets in passing argument 3 of ‘gst_element_query_duration’ differ in signedness [-Wpointer-sign] 
/usr/include/gstreamer-0.10/gst/gstutils.h:1049:25: note: expected ‘gint64 *’ but argument is of type ‘guint64 *’ 
/tmp/cckH1GSv.o: In function `toggle_paused': 
/home/vickey/work/gst-player-0.0.0/ui.c:43: undefined reference to `gtk_button_get_type' 
/home/vickey/work/gst-player-0.0.0/ui.c:43: undefined reference to `g_type_check_instance_cast' 
/home/vickey/work/gst-player-0.0.0/ui.c:43: undefined reference to `gtk_button_set_label' 
/home/vickey/work/gst-player-0.0.0/ui.c:49: undefined reference to `gtk_button_get_type' 
/home/vickey/work/gst-player-0.0.0/ui.c:49: undefined reference to `g_type_check_instance_cast' 
/home/vickey/work/gst-player-0.0.0/ui.c:49: undefined reference to `gtk_button_set_label' 
/tmp/cckH1GSv.o: In function `toggle_fullscreen': 
/home/vickey/work/gst-player-0.0.0/ui.c:60: undefined reference to `gtk_window_unfullscreen' 
/home/vickey/work/gst-player-0.0.0/ui.c:65: undefined reference to `gtk_window_fullscreen' 
/tmp/cckH1GSv.o: In function `destroy': 
/home/vickey/work/gst-player-0.0.0/ui.c:96: undefined reference to `gtk_main_quit' 
/ tmp/cckH1GSv.o: In function `key_press': 
/home/vickey/work/gst-player-0.0.0/ui.c:127: undefined reference to `gtk_main_quit' 
/tmp/cckH1GSv.o: In function `start': 
/home/vickey/work/gst-player-0.0.0/ui.c:167: undefined reference to `gtk_window_new' 
/home/vickey/work/gst-player-0.0.0/ui.c:169: undefined reference to `g_type_check_instance_cast' 
/home/vickey/work/gst-player-0.0.0/ui.c:169: undefined reference to `g_signal_connect_data' 
/home/vickey/work/gst-player-0.0.0/ui.c:172: undefined reference to `g_type_check_instance_cast' 
/home/vickey/work/gst-player-0.0.0/ui.c:172: undefined reference to `g_signal_connect_data' 
/home/vickey/work/gst-player-0.0.0/ui.c:175: undefined reference to `g_type_check_instance_cast' 
/home/vickey/work/gst-player-0.0.0/ui.c:175: undefined reference to `g_signal_connect_data' 
/home/vickey/work/gst-player-0.0.0/ui.c:178: undefined reference to `gtk_container_get_type' 
/home/vickey/work/gst-player-0.0.0/ui.c:178: undefined reference to `g_type_check_instance_cast' 
/home/vickey/work/gst-player-0.0.0/ui.c:178: undefined reference to `gtk_container_set_border_width' 
/home/vickey/work/gst-player-0.0.0/ui.c:180: undefined reference to `gtk_vbox_new' 
/home/vickey/work/gst-player-0.0.0/ui.c:182: undefined reference to `gtk_container_get_type' 
/home/vickey/work/gst-player-0.0.0/ui.c:182: undefined reference to `g_type_check_instance_cast' 
/home/vickey/work/gst-player-0.0.0/ui.c:182: undefined reference to `gtk_container_add' 
/home/vickey/work/gst-player-0.0.0/ui.c:184: undefined reference to `gtk_widget_show' 
/home/vickey/work/gst-player-0.0.0/ui.c:186: undefined reference to `gtk_hbox_new' 
/home/vickey/work/gst-player-0.0.0/ui.c:188: undefined reference to `gtk_box_get_type' 
/home/vickey/work/gst-player-0.0.0/ui.c:188: undefined reference to `g_type_check_instance_cast' 
/home/vickey/work/gst-player-0.0.0/ui.c:188: undefined reference to `gtk_box_pack_end' 
/home/vickey/work/gst-player-0.0.0/ui.c:190: undefined reference to `gtk_widget_show' 
/home/vickey/work/gst-player-0.0.0/ui.c:193: undefined reference to `gtk_drawing_area_new' 
/home/vickey/work/gst-player-0.0.0/ui.c:195: undefined reference to `gtk_box_get_type' 
/home/vickey/work/gst-player-0.0.0/ui.c:195: undefined reference to `g_type_check_instance_cast' 
/home/vickey/work/gst-player-0.0.0/ui.c:195: undefined reference to `gtk_box_pack_start' 
/home/vickey/work/gst-player-0.0.0/ui.c:197: undefined reference to `gtk_widget_set_size_request' 
/home/vickey/work/gst-player-0.0.0/ui.c:199: undefined reference to `gtk_widget_show' 
/home/vickey/work/gst-player-0.0.0/ui.c:203: undefined reference to `gtk_button_new_with_label' 
/home/vickey/work/gst-player-0.0.0/ui.c:205: undefined reference to `g_type_check_instance_cast' 
/home/vickey/work/gst-player-0.0.0/ui.c:205: undefined reference to `g_signal_connect_data' 
/home/vickey/work/gst-player-0.0.0/ui.c:208: undefined reference to `gtk_box_get_type' 
/home/vickey/work/gst-player-0.0.0/ui.c:208: undefined reference to `g_type_check_instance_cast' 
/home/vickey/work/gst-player-0.0.0/ui.c:208: undefined reference to `gtk_box_pack_start' 
/home/vickey/work/gst-player-0.0.0/ui.c:210: undefined reference to `gtk_widget_show' 
/home/vickey/work/gst-player-0.0.0/ui.c:216: undefined reference to `gtk_button_new_with_label' 
/home/vickey/work/gst-player-0.0.0/ui.c:218: undefined reference to `g_type_check_instance_cast' 
/home/vickey/work/gst-player-0.0.0/ui.c:218: undefined reference to `g_signal_connect_data' 
/home/vickey/work/gst-player-0.0.0/ui.c:221: undefined reference to `gtk_box_get_type' 
/home/vickey/work/gst-player-0.0.0/ui.c:221: undefined reference to `g_type_check_instance_cast' 
/home/vickey/work/gst-player-0.0.0/ui.c:221: undefined reference to `gtk_box_pack_start' 
/home/vickey/work/gst-player-0.0.0/ui.c:223: undefined reference to `gtk_widget_show' 
/home/vickey/work/gst-player-0.0.0/ui.c:228: undefined reference to `gtk_adjustment_new' 
/home/vickey/work/gst-player-0.0.0/ui.c:229: undefined reference to `gtk_adjustment_get_type' 
/home/vickey/work/gst-player-0.0.0/ui.c:229: undefined reference to `g_type_check_instance_cast' 
/home/vickey/work/gst-player-0.0.0/ui.c:229: undefined reference to `gtk_hscale_new' 
/home/vickey/work/gst-player-0.0.0/ui.c:231: undefined reference to `gtk_box_get_type' 
/home/vickey/work/gst-player-0.0.0/ui.c:231: undefined reference to `g_type_check_instance_cast' 
/home/vickey/work/gst-player-0.0.0/ui.c:231: undefined reference to `gtk_box_pack_end' 
/home/vickey/work/gst-player-0.0.0/ui.c:233: undefined reference to `g_type_check_instance_cast' 
/home/vickey/work/gst-player-0.0.0/ui.c:233: undefined reference to `g_signal_connect_data' 
/home/vickey/work/gst-player-0.0.0/ui.c:236: undefined reference to `gtk_widget_show' 
/home/vickey/work/gst-player-0.0.0/ui.c:239: undefined reference to `gtk_widget_show' 
/tmp/cckH1GSv.o: In function `init': 
/ home/vickey/work/gst-player-0.0.0/ui.c:245: undefined reference to `gdk_x11_drawable_get_xid' 
/tmp/cckH1GSv.o: In function `timeout': 
/home/vickey/work/gst-player-0.0.0/ui.c:275: undefined reference to `gtk_range_get_type' 
/home/vickey/work/gst-player-0.0.0/ui.c:275: undefined reference to `g_type_check_instance_cast' 
/home/vickey/work/gst-player-0.0.0/ui.c:275: undefined reference to `gtk_range_set_value' 
/tmp/cckH1GSv.o: In function `main': 
/home/vickey/work/gst-player-0.0.0/ui.c:285: undefined reference to `gtk_init' 
/home/vickey/work/gst-player-0.0.0/ui.c:293: undefined reference to `g_strdup' 
/home/vickey/work/gst-player-0.0.0/ui.c:295: undefined reference to `g_strdup_printf' 
/home/vickey/work/gst-player-0.0.0/ui.c:299: undefined reference to `g_idle_add' 
/home/vickey/work/gst-player-0.0.0/ui.c:300: undefined reference to `g_timeout_add' 
/home/vickey/work/gst-player-0.0.0/ui.c:302: undefined reference to `gtk_main' 
/home/vickey/work/gst-player-0.0.0/ui.c:304: undefined reference to `g_free' 
/tmp/cc9cDvJS.o: In function `bus_cb': 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:39: undefined reference to `g_log' 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:47: undefined reference to `gst_message_parse_error' 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:48: undefined reference to `g_free' 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:50: undefined reference to `g_log' 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:51: undefined reference to `g_error_free' 
/tmp/cc9cDvJS.o: In function `backend_init': 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:65: undefined reference to `gst_init' 
/tmp/cc9cDvJS.o: In function `backend_play': 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:79: undefined reference to `gst_pipeline_new' 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:81: undefined reference to `gst_element_factory_make' 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:82: undefined reference to `gst_element_factory_make' 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:84: undefined reference to `g_type_check_instance_cast' 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:84: undefined reference to `g_object_set' 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:86: undefined reference to `gst_bin_get_type' 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:86: undefined reference to `g_type_check_instance_cast' 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:86: undefined reference to `gst_bin_add' 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:90: undefined reference to `gst_pipeline_get_type' 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:90: undefined reference to `g_type_check_instance_cast' 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:90: undefined reference to `gst_pipeline_get_bus' 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:91: undefined reference to `gst_bus_add_watch' 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:92: undefined reference to `gst_object_unref' 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:95: undefined reference to `g_type_check_instance_cast' 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:95: undefined reference to `g_object_set' 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:97: undefined reference to `gst_x_overlay_get_type' 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:97: undefined reference to `gst_implements_interface_check' 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:99: undefined reference to `gst_x_overlay_get_type' 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:99: undefined reference to `gst_implements_interface_cast' 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:99: undefined reference to `gst_x_overlay_set_xwindow_id' 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:102: undefined reference to `gst_element_set_state' 
/tmp/cc9cDvJS.o: In function `backend_stop': 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:110: undefined reference to `gst_element_set_state' 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:111: undefined reference to `gst_object_get_type' 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:111: undefined reference to `g_type_check_instance_cast' 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:111: undefined reference to `gst_object_unref' 
/tmp/cc9cDvJS.o: In function `backend_pause': 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:119: undefined reference to `gst_element_set_state' 
/tmp/cc9cDvJS.o: In function `backend_resume': 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:125: undefined reference to `gst_element_set_state' 
/tmp/cc9cDvJS.o: In function `backend_reset': 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:131: undefined reference to `gst_element_seek' 
/tmp/cc9cDvJS.o: In function `backend_seek': 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:141: undefined reference to `gst_element_seek' 
/tmp/cc9cDvJS.o: In function `backend_seek_absolute': 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:151: undefined reference to `gst_element_seek' 
/tmp/cc9cDvJS.o: In function `backend_query_position': 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:164: undefined reference to `gst_element_query_position' 
/tmp/cc9cDvJS.o: In function `backend_query_duration': 
/home/vickey/work/gst-player-0.0.0/gst-backend.c:177: undefined reference to `gst_element_query_duration' 
collect2: ld returned 1 exit status 
make: *** [gst-player] Error 1 

我想我可能會丟失一些庫進口,但我無法弄清楚。謝謝

+0

什麼命令'pkg-config --libs gtk + -2.0'打印? – 2012-04-20 06:31:08

+0

-pthread -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 - lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0 – 2012-04-20 06:42:34

+0

嗯,對我來說很好看。 'libgtk-x11-2.0.so'在哪裏? 「nm -D /path/to/libgtk-x11-2.0.so | grep gtk_button_get_type'」命令顯示的是什麼? (顯然,你必須將路徑替換爲'libgtk-x11-2.0.so'。) – 2012-04-20 12:26:26

回答

3

最有可能的問題是因爲鏈接器沒有鏈接到庫,直到它在編譯中看到庫中的任何符號,因爲源在編譯時鏈接到庫之後出現。由於鏈接器不會鏈接庫,除非它在源庫中遇到庫中的符號,您將需要在編譯命令開始時移動源。目前Makefile提供源鏈接建立如下:

19 gst-player: ui.c gst-backend.c 
20  $(CC) $(CFLAGS) $(GTK_CFLAGS) $(GTK_LIBS) $(GST_CFLAGS) $(GST_LIBS) $+ -o [email protected] 

修改成:

19 gst-player: ui.c gst-backend.c 
20  $(CC) $+ $(CFLAGS) $(GTK_CFLAGS) $(GTK_LIBS) $(GST_CFLAGS) $(GST_LIBS) -o [email protected] 

(注意,現在的來源是$(CC)後右)。或者,您可以使用-Wl, --no-as-needed選項,讓連接器鏈接庫,而不管遇到庫中的符號。在這種情況下,Makefile的更改可能如下所示:

19 gst-player: ui.c gst-backend.c 
20  $(CC) -Wl,--no-as-needed $(CFLAGS) $(GTK_CFLAGS) $(GTK_LIBS) $(GST_CFLAGS) $(GST_LIBS) $+ -o [email protected] 

希望這有助於您!

+0

太棒了! :D。但可悲的是,它沒有運行,但編譯正確。 ** vickey @ tb:〜/ work/gst-player-0.0.0 $ ./gst-player Opening_Music.ogg **(gst-player:8342):警告**:錯誤:無法打開閱讀資源。 ' 該文件適用於MPlayer。我想知道現在可能是什麼問題。 – 2012-04-23 06:02:31