Gstreamer學習筆記----第一個helloworld程式
阿新 • • 發佈:2019-02-13
1.Ubuntu上安裝gstreamer庫:
apt-get install libgstreamer0.10-0
apt-get install libgstreamer0.10-dev
apt-get install libgstreamer0.10-0-dbg
2.編寫測試gstreamer庫的helloworld.c:
#include <stdio.h> #include <gst/gst.h> int main (int argc,char *argv[]) { const gchar *nano_str; guint major, minor, micro, nano; gst_init (&argc, &argv); gst_version (&major, &minor, µ, &nano); if (nano == 1) nano_str = "(CVS)"; else if (nano == 2) nano_str = "(Prerelease)"; else nano_str = ""; printf ("This program is linked against GStreamer %d.%d.%d %s\n", major, minor, micro, nano_str); return 0; }
這是個獲得gstreamer庫版本的測試用例。
3.編譯程式:
gcc -Wall helloworld.c -o helloworld $(pkg-config --cflags --libs gstreamer-0.10)
編譯時藉助了 pkg-config
pkg-config --cflags --libs gstreamer-0.10 會把gstreamer-0.10編譯所依賴的庫的路徑 標頭檔案的路徑全部幫你找出來,不用你再依次寫出。
(上面這條pkg-config --cflags --libs gstreamer-0.10 就相當於:
-pthread -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/gstreamer-0.10 -I/usr/include/libxml2 -pthread -L/usr/lib/i386-linux-gnu -lgstreamer-0.10 -lgobject-2.0 -lgmodule-2.0 -lxml2 -lgthread-2.0 -lrt -lglib-2.0)
4.執行helloworld結果: ./helloworld
This program is linked against GStreamer 0.10.32