1. 程式人生 > >qt5.7交叉編譯gstreamer-1.0

qt5.7交叉編譯gstreamer-1.0

一、交叉編譯glib
1.提前需先交叉編譯libffi
CC=/home/mjl/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-gcc ./configure --prefix=/home/mjl/build/libffi-3.2.1/install/arm/ --host=arm-linux-gnueabihf
2.提前需先交叉編譯zlib
CC=/home/mjl/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-gcc ./configure --prefix=/home/mjl/build/zlib-1.2.8/install/arm/ --host=arm-linux-gnueabihf
3.交叉編譯glib至本地
CC=/home/mjl/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-gcc ./configure --prefix=/home/mjl/build/glib-2.45.3/install/arm/ --host=arm-linux-gnueabihf LIBFFI_CFLAGS="-I/home/mjl/build/libffi-3.2.1/install/arm/lib/libffi-3.2.1/include"  LIBFFI_LIBS="-lffi -L/home/mjl/build/libffi-3.-I/2.1/install/lib" ZLIB_CFLAGS="-I/home/mjl/build/zlib-1.2.8/install/arm/include" ZLIB_LIBS="-lz -L/home/mjl/build/zlib-1.2.8/install/lib" glib_cv_stack_grows=no glib_cv_uscore=no ac_cv_func_posix_getpwuid_r=yes ac_cv_func_posix_getgrgid_r=yes ac_cv_lib_rt_clock_gettime=no glib_cv_monotonic_clock=yes
4.checking gcc ...no (config.log libstdc++.so.6: cannot open shared object file: No such file or directory)
解決方法 sudo apt-get install lib32stdc++6  lib32z1
5.接著執行會出現clock_gettime...
看網上說,export LDFLAGS=" lrt "(不能用)
用下邊的方法LDFLAGS=" -lrt "
CC=/home/mjl/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-gcc ./configure LDFLAGS=" -lrt " --prefix=/home/mjl/build/gstreamer1.0/install/arm/ --host=arm-linux-gnueabihf LIBFFI_CFLAGS="-I/home/mjl/build/libffi-3.2.1/install/arm/lib/libffi-3.2.1/include"  LIBFFI_LIBS="-lffi -L/home/mjl/build/libffi-3.-I/2.1/install/lib" ZLIB_CFLAGS="-I/home/mjl/build/zlib-1.2.8/install/arm/include" ZLIB_LIBS="-lz -L/home/mjl/build/zlib-1.2.8/install/lib" glib_cv_stack_grows=no glib_cv_uscore=no ac_cv_func_posix_getpwuid_r=yes ac_cv_func_posix_getgrgid_r=yes ac_cv_lib_rt_clock_gettime=no glib_cv_monotonic_clock=yes
6.安裝glib 時出現glib msgfmt.. no (這個問題極易出現在Ubuntu 上)
解決方案:apt-get install gettest
7.安裝glib 時出現 error: Could not find a glib-genmarshal in your PATH,
解決方案:先在主機安裝 apt-get install libglib2.0-dev
8.make -j 4
9.make install
10.交叉編譯至樹莓派
①.CC=/home/mjl/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-gcc ./configure LDFLAGS=" -lrt " --prefix=/mnt/rasp-pi-rootfs/home/mjl/build/gstreamer1.0/install/arm/ --host=arm-linux-gnueabihf LIBFFI_CFLAGS="-I/home/mjl/build/libffi-3.2.1/install/arm/lib/libffi-3.2.1/include"  LIBFFI_LIBS="-lffi -L/home/mjl/build/libffi-3.-I/2.1/install/lib" ZLIB_CFLAGS="-I/home/mjl/build/zlib-1.2.8/install/arm/include" ZLIB_LIBS="-lz -L/home/mjl/build/zlib-1.2.8/install/lib" glib_cv_stack_grows=no glib_cv_uscore=no ac_cv_func_posix_getpwuid_r=yes ac_cv_func_posix_getgrgid_r=yes ac_cv_lib_rt_clock_gettime=no glib_cv_monotonic_clock=yes
②.make -j 4
③.make install
××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
二、交叉編譯gstreamer1.0
安裝gstreamer-1.10.1
1.交叉編譯至樹莓派
①.export PKG_CONFIG_PATH=/home/mjl/build/zlib-1.2.8/install/arm/lib/pkgconfig:/mnt/rasp-pi-rootfs/home/mjl/build/gstreamer1.0/install/arm/lib/pkgconfig:/home/mjl/build/libxml2-2.6.26/install/arm/lib/pkgconfig:$PKG_CONFIG_PATH
②.CC=/home/mjl/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-gcc ./configure --prefix=/mnt/rasp-pi-rootfs/home/mjl/build/gstreamer1.0/install/arm/ --host=arm-linux-gnueabihf  --disable-registry --disable-loadsave --disable-gtk-doc ac_cv_func_register_printf_function=no --disable-tests --disable-valgrind --disable-debug --disable-gst-debug 
3.提示缺少什安裝什麼
4.cannot find -lgobject-2.0 lgmodule-2.0 lglib-2.0
解決辦法:export PKG_CONFIG_PATH=/home/mjl/build/glib-2.45.3/install/arm/lib/pkgconfig:$PKG_CONFIG_PATH
5.warning: libgstbase-1.0.so.0, needed by ../../libs/gst/net/.libs/libgstnet-1.0.so, not found
解決辦法,查詢sudo find / -name libgstnet-1.0.so
我的在之前安裝的地方,/home/mjl/build/gstreamer-1.10.0/libs/gst/net/.libs/libgstnet-1.0.so  
cd /home/mjl/build/gstreamer-1.10.0/libs/gst/base/.libs
cp libgstbase-1.0.so libgstbase-1.0.so.0 libgstbase-1.0.so.0.1000.0 /home/mjl/opt/gcc-4.7-linaro-rpi-gnueabihf/arm-linux-gnueabihf/libc/lib/arm-linux-gnueabihf
重新./configure
6.make -j 4
7.sudo make install
8.交叉編譯至本地
①export PKG_CONFIG_PATH=/home/mjl/build/zlib-1.2.8/install/arm/lib/pkgconfig:/home/mjl/build/gstreamer1.0/install/arm/lib/pkgconfig:/home/mjl/build/libxml2-2.6.26/install/arm/lib/pkgconfig:$PKG_CONFIG_PATH
②CC=/home/mjl/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-gcc ./configure --prefix=/home/mjl/build/gstreamer1.0/install/arm/ --host=arm-linux-gnueabihf  --disable-registry --disable-loadsave --disable-gtk-doc ac_cv_func_register_printf_function=no --disable-tests --disable-valgrind --disable-debug --disable-gst-debug 
③make -j 4
④sudo make install
××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
三、交叉編譯gst-plugins-base
1.交叉編譯至樹莓派
①.export PKG_CONFIG_PATH=/home/mjl/build/zlib-1.2.8/install/arm/lib/pkgconfig:/mnt/rasp-pi-rootfs/home/mjl/build/gstreamer1.0/install/arm/lib/pkgconfig:$PKG_CONFIG_PATH
②CC=/home/mjl/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-gcc ./configure --prefix=/mnt/rasp-pi-rootfs/home/mjl/build/gstreamer1.0/install/arm/ --host=arm-linux-gnueabihf  --disable-valgrind --disable-x --disable-gnome_vfs --disable-alsa --disable-ogg --disable-pango --disable-theora --disable-vorbis --disable-examples  
③make -j 4
④sudo make install


2.交叉編譯至本地
①.export PKG_CONFIG_PATH=/home/mjl/build/zlib-1.2.8/install/arm/lib/pkgconfig://home/mjl/build/gstreamer1.0/install/arm/lib/pkgconfig:$PKG_CONFIG_PATH
②CC=/home/mjl/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-gcc ./configure --prefix=/home/mjl/build/gstreamer1.0/install/arm/ --host=arm-linux-gnueabihf  --disable-valgrind --disable-x --disable-gnome_vfs --disable-alsa --disable-ogg --disable-pango --disable-theora --disable-vorbis --disable-examples  
③make -j 4
④sudo make install
××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
四、交叉編譯gst-plugins-good
1.交叉編譯至樹莓派
①export PKG_CONFIG_PATH=/home/mjl/build/zlib-1.2.8/install/arm/lib/pkgconfig:/mnt/rasp-pi-rootfs/home/mjl/build/gstreamer1.0/install/arm/lib/pkgconfig:$PKG_CONFIG_PATH
②CC=/home/mjl/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-gcc ./configure --prefix=/mnt/rasp-pi-rootfs/home/mjl/build/gstreamer1.0/install/arm/ --host=arm-linux-gnueabihf  -disable-x --disable-xshm --disable-cairo --disable-xvideo --disable-esd --disable-shout2 --disable-gconf --disable-gdk_pixbuf --disable-hal --disable-libpng --disable-oss --disable-oss4
③make -j 4
④sudo make install


2.交叉編譯至本地
①export PKG_CONFIG_PATH=/home/mjl/build/zlib-1.2.8/install/arm/lib/pkgconfig:/home/mjl/build/gstreamer1.0/install/arm/lib/pkgconfig:$PKG_CONFIG_PATH
②CC=/home/mjl/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-gcc ./configure --prefix=/home/mjl/build/gstreamer1.0/install/arm/ --host=arm-linux-gnueabihf  -disable-x --disable-xshm --disable-cairo --disable-xvideo --disable-esd --disable-shout2 --disable-gconf --disable-gdk_pixbuf --disable-hal --disable-libpng --disable-oss --disable-oss4
③make -j 4
④sudo make install
××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
五、交叉編譯qt5
1.mkdir /mnt/rasp-pi-rootfs
2.sudo mount -o loop,offset=70254592 2016-11-25-raspbian-jessie.img /mnt/rasp-pi-rootfs
3.當掛載完成後,請進入cd /mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/檢視兩個so檔案,命令ls -l libdl.so 和ls -l libm.so,看清其指向的檔案是否如lrwxrwxrwx 1 root root 13 Jan 10 15:30 libdl.so -> libdl-2.19.so ,如果不是,先刪除原來的軟連線(sudo rm libdl.so),執行sudo ln -s libdl-2.19.so libdl.so(重新建立軟連線),如果arm-linux-gnueabihf資料夾下不存在libdl-2.19.so,看看剛才ls命令其指向的檔案在哪(或者sudo find /mnt/rasp-pi-rootfs -name libdl-2.19.so我的是在/mnt/rasp-pi-rootfs/lib/arm-linux-gnueabihf/下),拷貝至此(/mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf)即可,執行sudo ln -s libdl-2.19.so libdl.so,對於libm同樣操作,原因:防止出現:undefined reference to `__dlopen’等問題,參照http://blog.csdn.net/scylhy/article/details/52818779。
4.cd ~/opt/cross-compile-tools
5.sudo ./fixQualifiedLibraryPaths /mnt/rasp-pi-rootfs/ ~/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-gcc
6.export PKG_CONFIG_PATH=/home/mjl/build/gstreamer1.0/install/arm/lib/pkgconfig:$PKG_CONFIG_PATH
(本地和樹莓派各有一個gstreamer1.0,因為如果本地沒有的話,export pkgconfig無法識別,如果樹莓派沒有的話,因為sysroot 字首,導致其編譯時候找不到本地檔案(會多了字首),如果去掉sysroot的話,許多自帶的庫無法使用,如egl等等,所以折中的辦法是樹莓派和本地的gstreamer1.0各編譯一次)
7.cd ~/opt/qt-everywhere-opensource-src-5.7.1/qtbase
8../configure -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=~/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf- -sysroot /mnt/rasp-pi-rootfs -opensource -confirm-license -optimized-qmake -reduce-exports -release -make libs -prefix /usr/local/qt5pi -hostprefix /usr/local/qt5pi -gstreamer 1.0 -v
0.make -j 4
10.sudo make install
11.cd ~/opt/qt-everywhere-opensource-src-5.7.1/
12.執行如下命令
    for MODULE in qtimageformats qtsvg  qtscript qtxmlpatterns qtdeclarative qtsensors qt3d qtgraphicaleffects  qtlocation ; do  cd $MODULE;  /usr/local/qt5pi/bin/qmake .;  make -j4;  sudo make install;  cd ..; done
13. cd~/opt/
14.sync; sudo umount /mnt/rasp-pi-rootfs (取消掛載)
15.sudo dd bs=1M if=2016-11-25-raspbian-jessie.img of=/dev/sdb; sync (燒錄至記憶體卡)(看清of後的地址,可用命令fdisk -l 檢視,我就是直接用的sdb,然後系統都沒了,要不然也沒機會再熟悉一遍,也沒機會把經驗總結一下--!)
到此就完成了交叉編譯的環境配置,其他配置參照我之前的交叉編譯的文章。
16.宣告一下,因為樹莓派板子燒了也不確定,交叉編譯的gstreamer1.0能不能使用,等我新板子回來我再驗證一下。
17.其實我覺得如果嫌交叉編譯麻煩,可以在樹莓派上安裝gstreamer及gst-plugins-..然後交叉編譯qt5.7時,export PKG_CONFIG_PATH=...,其實我有多少次都有種使用此種方法的衝動,但是不服輸的心態讓我覺得明知山有虎偏向虎山行!


引用連結:http://blog.csdn.net/water_cow/article/details/8728111

http://blog.csdn.net/water_cow/article/details/8728216

http://blog.csdn.net/xueyeguiren8/article/details/54345013