使用新的 glib 版本编译 gstreamer

Compiling gstreamer with new glib version

我安装了 CentOS 6.7。我需要编译 GStreamer 1.4.5(或任何 1.x),因为 CentOS 发行版有 GStreamer 0.10。 GStreamer 1.x 要求 GLib2 >= 2.32 左右,但 CentOS 有 2.28.8。因此,我使用特定位置 /usr/mylibs(作为 --prefix 参数)编译了 GLib 2.44.1。

ll /usr/mylibs/lib
total 26008
drwxr-xr-x.  3 root root     4096 Sep  3 16:48 gio
drwxr-xr-x.  3 root root     4096 Sep  3 16:48 glib-2.0
drwxr-xr-x.  3 root root     4096 Sep  3 15:44 libffi-3.2.1
-rwxr-xr-x.  1 root root     1132 Sep  3 16:48 libgio-2.0.la
lrwxrwxrwx.  1 root root       22 Sep  3 16:48 libgio-2.0.so -> libgio-2.0.so.0.4400.1
lrwxrwxrwx.  1 root root       22 Sep  3 16:48 libgio-2.0.so.0 -> libgio-2.0.so.0.4400.1
-rwxr-xr-x.  1 root root  6208700 Sep  3 16:48 libgio-2.0.so.0.4400.1
-rwxr-xr-x.  1 root root     1005 Sep  3 16:48 libglib-2.0.la
lrwxrwxrwx.  1 root root       23 Sep  3 16:48 libglib-2.0.so -> libglib-2.0.so.0.4400.1
lrwxrwxrwx.  1 root root       23 Sep  3 16:48 libglib-2.0.so.0 -> libglib-2.0.so.0.4400.1
-rwxr-xr-x.  1 root root  3172134 Sep  3 16:48 libglib-2.0.so.0.4400.1
-rwxr-xr-x.  1 root root     1059 Sep  3 16:48 libgmodule-2.0.la
lrwxrwxrwx.  1 root root       26 Sep  3 16:48 libgmodule-2.0.so -> libgmodule-2.0.so.0.4400.1
lrwxrwxrwx.  1 root root       26 Sep  3 16:48 libgmodule-2.0.so.0 -> libgmodule-2.0.so.0.4400.1
-rwxr-xr-x.  1 root root    39251 Sep  3 16:48 libgmodule-2.0.so.0.4400.1
-rwxr-xr-x.  1 root root     1060 Sep  3 16:48 libgobject-2.0.la
lrwxrwxrwx.  1 root root       26 Sep  3 16:48 libgobject-2.0.so -> libgobject-2.0.so.0.4400.1
lrwxrwxrwx.  1 root root       26 Sep  3 16:48 libgobject-2.0.so.0 -> libgobject-2.0.so.0.4400.1
-rwxr-xr-x.  1 root root  1188762 Sep  3 16:48 libgobject-2.0.so.0.4400.1
-rwxr-xr-x.  1 root root     1054 Sep  3 16:48 libgthread-2.0.la
lrwxrwxrwx.  1 root root       26 Sep  3 16:48 libgthread-2.0.so -> libgthread-2.0.so.0.4400.1
lrwxrwxrwx.  1 root root       26 Sep  3 16:48 libgthread-2.0.so.0 -> libgthread-2.0.so.0.4400.1
-rwxr-xr-x.  1 root root     9001 Sep  3 16:48 libgthread-2.0.so.0.4400.1
-rw-r--r--.  1 root root   921042 Sep  3 16:15 libpcre16.a
-rwxr-xr-x.  1 root root      931 Sep  3 16:15 libpcre16.la
lrwxrwxrwx.  1 root root       18 Sep  3 16:15 libpcre16.so -> libpcre16.so.0.2.5
lrwxrwxrwx.  1 root root       18 Sep  3 16:15 libpcre16.so.0 -> libpcre16.so.0.2.5
-rwxr-xr-x.  1 root root   618161 Sep  3 16:15 libpcre16.so.0.2.5
-rw-r--r--.  1 root root   893956 Sep  3 16:15 libpcre32.a
-rwxr-xr-x.  1 root root      931 Sep  3 16:15 libpcre32.la
lrwxrwxrwx.  1 root root       18 Sep  3 16:15 libpcre32.so -> libpcre32.so.0.0.5
lrwxrwxrwx.  1 root root       18 Sep  3 16:15 libpcre32.so.0 -> libpcre32.so.0.0.5
-rwxr-xr-x.  1 root root   593479 Sep  3 16:15 libpcre32.so.0.0.5
-rw-r--r--.  1 root root   975726 Sep  3 16:15 libpcre.a
-rw-r--r--.  1 root root    46462 Sep  3 16:15 libpcrecpp.a
-rwxr-xr-x.  1 root root      965 Sep  3 16:15 libpcrecpp.la
lrwxrwxrwx.  1 root root       19 Sep  3 16:15 libpcrecpp.so -> libpcrecpp.so.0.0.1
lrwxrwxrwx.  1 root root       19 Sep  3 16:15 libpcrecpp.so.0 -> libpcrecpp.so.0.0.1
-rwxr-xr-x.  1 root root    43351 Sep  3 16:15 libpcrecpp.so.0.0.1
-rwxr-xr-x.  1 root root      917 Sep  3 16:15 libpcre.la
-rw-r--r--.  1 root root    21720 Sep  3 16:15 libpcreposix.a
-rwxr-xr-x.  1 root root      979 Sep  3 16:15 libpcreposix.la
lrwxrwxrwx.  1 root root       21 Sep  3 16:15 libpcreposix.so -> libpcreposix.so.0.0.3
lrwxrwxrwx.  1 root root       21 Sep  3 16:15 libpcreposix.so.0 -> libpcreposix.so.0.0.3
-rwxr-xr-x.  1 root root    18917 Sep  3 16:15 libpcreposix.so.0.0.3
lrwxrwxrwx.  1 root root       21 Sep  3 16:43 libpcre.so -> /lib/libpcre.so.1.2.5
-rwxr-xr-x.  1 root root   693207 Sep  3 16:47 libpcre.so.1
-rwxr-xr-x.  1 root root   693207 Sep  3 16:47 libpcre.so.1.2.5
-rwxr-xr-x.  1 root root 10381922 Sep  3 16:00 libpython2.7.a
drwxr-xr-x.  2 root root     4096 Sep  3 16:48 pkgconfig
drwxr-xr-x. 28 root root    20480 Sep  3 16:03 python2.7

现在我正在尝试编译 GStreamer 1.4.5:

export GLIB_CFLAGS="-I/usr/mylibs/include/glib-2.0 -I/usr/mylibs/lib/glib-2.0/include" && export GLIB_LIBS="-L/usr/mylibs -L/usr/mylibs/lib/glib-2.0" && export GIO_CFLAGS="-I/usr/mylibs/include -I/usr/mylibs/include/gio-unix-2.0" && export GIO_LIBS="-L/usr/mylibs -L/usr/mylibs/lib/gio" && export PYTHON=/usr/mylibs/bin/python
./configure --prefix=/usr/mylib
or
./configure 
make

它一直有效,直到出现此错误:

Making all in helpers
make[4]: Entering directory `/root/gstreamer/gstreamer-1.4.5/libs/gst/helpers'
  CC       gst_plugin_scanner-gst-plugin-scanner.o
  CCLD     gst-plugin-scanner
gst_plugin_scanner-gst-plugin-scanner.o: In function `main':
/root/gstreamer/gstreamer-1.4.5/libs/gst/helpers/gst-plugin-scanner.c:45: undefined reference to `g_malloc'
/root/gstreamer/gstreamer-1.4.5/libs/gst/helpers/gst-plugin-scanner.c:55: undefined reference to `g_free'
../../../gst/.libs/libgstreamer-1.0.so: undefined reference to `g_param_spec_object'
../../../gst/.libs/libgstreamer-1.0.so: undefined reference to `g_utf8_validate'
../../../gst/.libs/libgstreamer-1.0.so: undefined reference to `g_date_get_month'
../../../gst/.libs/libgstreamer-1.0.so: undefined reference to `g_value_get_float'
../../../gst/.libs/libgstreamer-1.0.so: undefined reference to `g_checksum_update'
../../../gst/.libs/libgstreamer-1.0.so: undefined reference to `g_memdup'
../../../gst/.libs/libgstreamer-1.0.so: undefined reference to `g_type_interface_peek'
../../../gst/.libs/libgstreamer-1.0.so: undefined reference to `g_value_set_int64'
../../../gst/.libs/libgstreamer-1.0.so: undefined reference to `g_thread_pool_new'
...
../../../gst/.libs/libgstreamer-1.0.so: undefined reference to `g_param_spec_ref'
collect2: ld returned 1 exit status
make[4]: *** [gst-plugin-scanner] Error 1
make[4]: Leaving directory `/root/gstreamer/gstreamer-1.4.5/libs/gst/helpers'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/root/gstreamer/gstreamer-1.4.5/libs/gst'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/root/gstreamer/gstreamer-1.4.5/libs'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/gstreamer/gstreamer-1.4.5'
make: *** [all] Error 2

我错过了什么?请帮忙。

您似乎误解了 *_LIBS 环境变量的工作原理。它应该包含 link 所需的标志以变得能说会道;像“-L/usr/mylibs/lib -lglib-2.0”这样的东西应该可以工作。

-L… 标志为 linker 提供了一个额外的位置来查找共享库(libglib-2.0.so),但在您的标志中您已经为它提供了一个高于它需要的目录 (/usr/mylibs) 和一个子目录 (/usr/mylibs/lib/glib-2.0)。 -l... 标志告诉它要查找的特定库,但你完全忽略了它。

我在 CentOS 6.3 虚拟机上遇到了同样的问题。我试图针对 glib 2.32.4 构建 GStreamer 1.4.5。如 this message thread 所示,当您尝试构建时,似乎链接了不正确的库(不是 2.0 的!)而不是在 GLIB_CFLAGS 中明确定义目录路径,您可以使用 PKG_CONFIG_PATH.

找到 pkgconfig 目录并确保您已安装的包驻留在其中(如 glib-2.0、gobject-2.0、gthread-2.0 等)(在我的计算机上我的路径是:/usr/local/lib/pkconfig/。)我在你的目录列表中注意到你提供了你确实有 pkg​​config。

先导出变量,再配置,最后make:

export PKG_CONFIG_PATH=/usr/mylibs/lib/pkgconfig/ ./configure make

GStreamer 现在应该可以正确构建。