0

我正在尝试从谷歌代码编译简单的gst 播放器。我已经修复并安装了缺少的库,现在我收到链接器错误

vickey@tb:~/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

我想我可能会丢失一些库导入,但我无法弄清楚。谢谢

4

1 回答 1

4

问题很可能是因为链接器在编译中看到库中的任何符号之前不会链接到库,因为源代码出现在编译时链接到库之后。由于链接器在从源代码中遇到库中的符号之前不会链接到库,因此您需要在编译命令的开头移动源代码。目前Makefile源链接中的提供构建如下:

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

将其更改为:

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

(请注意,现在来源就在 之后$(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 $@  

希望这可以帮助!

于 2012-04-20T17:27:56.880 回答