1. 程式人生 > >VLC3.0 win32裁剪及編譯

VLC3.0 win32裁剪及編譯

=======2018.9.28更新=======

一句話總結,無論編譯哪個平臺,各個倉庫的版本號一定要對上,沒有版本號的,也要找提交日期相近的。

=========================

首先提一下,由於工具本身的問題,mingw-w64-gcc和mingw-w64-g++要用5.0以下的版本,又要c++11支援,那就推薦4.9。不然64位編譯過不了。

環境安裝這些就按VLC官方指南就好,除了上面提到的,也不細說了。

假設環境都弄好了,contrib裡的一大堆三方庫也都下載好了(這個比較花時間,可以手動下,找映象什麼的),下面提供一個shell,整合一下命令列,並且把精簡也寫在裡面了。我這邊測是可以用的,至少可以做個參考。。。

#! /bin/sh

set -e



# vlc win32 complie shell by yangxun



# function define

diagnostic()

{

    echo "[email protected]" 1>&2;

}



checkfail()

{

    if [ ! $? -eq 0 ]; then

        diagnostic "$1"

        exit 1

    fi

}



# arg get

while [ $# -gt 0 ]; do

    case $1 in

        --help|-h)

            echo "Use -a to set Host triplet"

            echo "  i686-w64-mingw32 for Windows 32-bits"

            echo "  x86_64-w64-mingw32 for Windows 64-bits"

            exit 0

            ;;

        -a)

            HOST_TRIPLET=$2

            shift

            ;;

    esac

    shift

done



# set default host triplet

if [ -z ${HOST_TRIPLET} ]; then

    #diagnostic "*** No HOST_TRIPLET defined,using i686-w64-mingw32"

    diagnostic "*** No HOST_TRIPLET defined,using -a to set it"

    exit 1

    #HOST_TRIPLET="i686-w64-mingw32"

else

    diagnostic "*** HOST_TRIPLET=${HOST_TRIPLET}"

fi



# detect build folder

if [ ${HOST_TRIPLET} = "i686-w64-mingw32" ]; then

    MY_BUILD_FOLDER="win32"

fi

if [ ${HOST_TRIPLET} = "x86_64-w64-mingw32" ]; then

    MY_BUILD_FOLDER="win64"

fi



# built

CONTRIB_CONFIG="

 --disable-gcrypt

 --disable-ssh2

 --disable-vncclient

 --disable-projectM

 --disable-bluray

 --disable-qt

 --disable-qtsvg

 --disable-sdl

 --disable-SDL_image

 --enable-glew"

mkdir -p contrib/${MY_BUILD_FOLDER}

cd contrib/${MY_BUILD_FOLDER}

../bootstrap --host=${HOST_TRIPLET} ${CONTRIB_CONFIG}

make fetch

checkfail "contrib fetch failed"

make

checkfail "contrib make failed"

rm -f ../i686-w64-mingw32/bin/moc ../i686-w64-mingw32/bin/uic ../i686-w64-mingw32/bin/rcc

if [ ${HOST_TRIPLET} != "i686-w64-mingw32" ]; then

    ln -sf ${HOST_TRIPLET} ../i686-w64-mingw32

fi



# go back

cd -



# compile vlc

OPTIONS="

      --enable-update-check

      --enable-lua

      --enable-faad

      --enable-flac

      --enable-theora

      --enable-twolame

      --enable-avcodec --enable-merge-ffmpeg

      --enable-dca

      --enable-mpc

      --enable-libass

      --enable-x264

      --enable-schroedinger

      --enable-realrtsp

      --enable-live555

      --enable-dvdread

      --enable-shout

      --enable-goom

      --enable-caca

      --enable-qt

      --enable-skins2

      --enable-sse --enable-mmx

      --enable-libcddb

      --enable-zvbi --disable-telx

      --enable-nls

      --disable-update-check

      --disable-libcrypt

      --disable-lua

      --disable-goom

      --disable-projectm

      --disable-vsxu

      --disable-vnc

      --disable-vcd

      --disable-libcddb

      --disable-freerdp

      --disable-opencv

      --disable-dc1394

      --disable-dv1394

      --disable-dvdread

      --disable-dvdnav

      --disable-bluray

      --disable-sdl-image

      --disable-skins2

      --disable-qt"

./bootstrap

mkdir -p ${MY_BUILD_FOLDER} && cd ${MY_BUILD_FOLDER}

export PKG_CONFIG_LIBDIR=$HOME/vlc/contrib/${HOST_TRIPLET}/lib/pkgconfig

../configure --host=${HOST_TRIPLET} --build=x86_64-pc-linux-gnu ${OPTIONS}

make

checkfail "vlc make failed"

make package-win32-zip

checkfail "vlc make package failed"

把這個放在vlc原始碼根目錄下執行即可。

精簡主要是ffmpeg精簡和去掉一些三方庫,ffmpeg這個在contrib/src/ffmpeg/rules.mak裡配。改FFMPEGCONF變數即可,可以在其原始碼目錄執行./configure --help來看具體可以配哪些。