This is the 23rd day of my participation in the August More Text Challenge.More challenges in August
VLC source code compilation — Cross-compile x86 and X64 versions for Linux (with pit record)
- The official documentation address: wiki.videolan.org/Win32Compil…
- Github address: github.com/videolan/vl…
Reference Address:
- VMware Ubuntu installation process in detail: (very useful) blog.csdn.net/stpeace/art…
- Streaming media 02: Linux cross compile VLC – 2.2.1: higoge. Making. IO / 2015/07/17 /…
- VLC – 2.2.4 cross-compilation UbuntuX64_1604_Desktop compile Windows vlc:blog.csdn.net/longji/arti…
1. Compile environment
Win10, Ubuntu 16.0.4, Linux 64-bit, Vlc 2.2.4, VMware Workstation 14.
Download address:
Ubuntu download address: http://releases.ubuntu.com/16.04/ubuntu-16.04-desktop-amd64.iso
VLC32 a dependent libraries download address: https://download.csdn.net/download/u012534831/10737727
VLC64 a dependent libraries download address: https://download.csdn.net/download/u012534831/10737729
The original download address: (through wall) : http://download.videolan.org/pub/videolan/contrib/x86_64-w64-mingw32
Mingw32 and 64 original download address: http://ftp.jp.debian.org/debian/pool/main/m/mingw-w64/
VLC2.2.4 source download address: https://blog.csdn.net/wangyequn1124/article/details/69247220
2. Preparation
Compiling VLC source code requires some software support, and some software is also needed during compilation.
- Under Linux 64-bit, apt-get installation software is available on the Internet. I recommend using aptitude command to install. If not, install aptitude first, because aptitude can help solve the dependence of the software.
$ sudo apt-get install aptitude
Copy the code
-
As the default ubuntu source is the Ubuntu website, the network speed needs to be improved slightly. Therefore, it is recommended to change the domestic source first. http://www.zgljl2012.com/ubuntu-xiu-gai-ubuntude-apt-getyuan-wei-a-li-yun-yuan-de-fang-fa/
-
It is recommended to install VIm before replacing a domestic source. Use VIM to open the file and then overwrite the original content.
$ sudo apt-get install vim
Copy the code
3. Compilation depends on software installation
CTRL + Alt +T, open the command line and execute the following commands in sequence:
$sudo aptitude install gcc-mingw-w64-i686 g++-mingw-w64-i686 mingw-w64-tools $sudo aptitude install gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 mingw-w64-tools # $sudo aptitude install lua5.2 libtool $sudo aptitude install libtool automake autoconf autopoint make gettext $ sudo aptitude install pkg-config $ sudo aptitude install qt4-dev-tools qt5-default $ sudo aptitude install git subversion $ sudo aptitude install cmake cvs $ sudo aptitude install wine64-development-tools libwine-dev zip p7zip nsis bzip2 # wine-dev for creating Win32 packages $ sudo aptitude install yasm ragel ant default-jdk protobuf-compiler dos2unix $ sudo aptitude updateCopy the code
Install the ttF-Mscorefonts-Installer config page. Press TAB, select OK or Yes, and press Enter.
4. Execute the script
Save the following to the script jb.sh
#! /bin/sh # This script enforces statically linking of libgcc, libstdc++-6, and libpthread, # without needing to rebuild gcc and mingw-w64 from scratch. # -static-libgcc -static-libstdc++ flags can not be used in a libtool build system, # as libtool removes flags that it doesn't understand. move() { [ -f $1 ] || return 1 mkdir -p old/ mv -v $* old/ return 0 } for x in i686 x86_64 do library_path_list=`$x-w64-mingw32-gcc -v /dev/null 2>&1 | grep ^LIBRARY_PATH|cut -d= -f2|sort|uniq` IFS=':' for i in $library_path_list do cd $i move libstdc++-6.dll libstdc++.dll.a libgcc_s.a libgcc_s_sjlj-1.dll && ln -s libgcc_eh.a libgcc_s.a move libpthread.dll.a libwinpthread.dll.a move libwinpthread-1.dll [ -d ../bin ] && cd .. /bin && move libwinpthread-1.dll done done exit 0Copy the code
Then execute the script:
$ sh j8.sh
Copy the code
5, decompress the source code
$tar xJvf vlc-2.2.4.tar.xz $CD vlc-2.2.4/Copy the code
6. Prepare for precompilation
Contrib /x86_64 && CD contrib/x86_64: contrib/x86_64. /bootstrap --host=x86_64-w64-mingw32 make prebuilt ## Manual building, website said takes time, and also very easy to get wrong, don't, for example # # -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- # # (recommend, speed) method 3: $mkdir win32 = contrib; $CD contrib = contrib; CD win32 $mv ~/vlc-contrib-i686-w64-mingw32-latest.tar.bz2 vlc-contrib-i686-w64-mingw32-latest.tar.bz2 ## 64-bit compiler $mkdir x86_64; CD x86_64 $mv ~/vlc-contrib-x86_64-w64-mingw32-latest.tar.bz2 vlc-contrib-x86_64-w64-mingw32-latest.tar.bz2 ## Start precompiling 32 bits $.. /bootstrap --build=i686-w64-mingw32 $make prebuilt # /bootstrap --build=x86_64-w64-mingw32 $ make prebuiltCopy the code
Return to source code root after precompilation (vLC-2.2.4)
$ cd .. /.. /Copy the code
7. Prepare to compile source code
$./bootstrap ## 32 bit $mkdir win32 && CD win32 ## 64 bit $mkdir x86_64 && CD x86_64 ## 32 bit export PKG_CONFIG_LIBDIR=$HOME/vlc-2.2.4/contrib/i686-w64-mingw32/lib/pkgconfig ## 64-bit export PKG_CONFIG_LIBDIR=$HOME/vlc-2.2.4/contrib/x86_64-w64-mingw32/lib/pkgconfig / extras/package/win32 / configure. Sh for win32 compilation script source extract got # # under Linux 64 - bit compiled windows32, this process, there will be a wine update process, automatic $... / extras/package/win32 / configure. Sh - host = host - i686 w64 - mingw32 - build = x86_64 - PC - # # under the Linux 64 - bit Linux - gnu compiler windows64 a $ . /configure --host=HOST-x86_64-w64-mingw32 --build=x86_64-pc-linux-gnu ##See '.. /configure --help' for more information.Copy the code
8, build,
$make -- j4 ##Copy the code
9, packaging,
$wine./vlc-2.2.4/vlc.exe $make package-win32-7zip # Generate vlC-2.2.4-win64.7z and Symbols-2.2.4. Copy it to Windows, decompress it, and run it. This step will download the npapi-vLC source code to x86_64/npapi-vlc and compile it, overwriting the original x86_64/npapi-vlc file. Need a VPN. $make package-win32-debug-7zip # generate vlC-2.2.4-win64-debug.7zCopy the code
10. Tread pit records
- If an error occurs while installing dependent software:
UBuntu software installation message: Reading the package list… Finished Analyzing software package dependency tree reading status information… Completion E: Unable to find package build-essential
$sudo aptitude update $sudo aptitude update ##Copy the code
- Qt4-default qT4-default qT4-default qT4-default
qt4-dev-tools, qt5-default (or qt4-default if qt plugin build fails)
- The sh script runs, however, because Linux is coded differently from Windows, where newlines are /n and Windows is /r/n. Therefore, you need to install the dos2UNIX software and convert the format before running the script.
$ sudo aptitude install dos2unix
$ dos2unix jb.sh
$ sh jb.sh
Copy the code
- Error: LibVLC requires mingw-runtime version 3.15 or higher, or mingw-w64 version 3.0 or higher! LibVLC requires mingw-runtime version 3.15 or higher, or mingw-w64 version 3.0 or higher! Because the MINGW version is too low, you can reinstall the higher version.
## Reference article: https://blog.csdn.net/mengzhengjie/article/details/46680281 # # to http://ftp.jp.debian.org/debian/pool/main/m/mingw-w64/ Download the required software package, note that the 64-bit need to modify i686 to (x86-64) ## (select download version greater than 3.15, Mingw-w64-common_3.0-3_all. deb ## mingw-w64-i686-dev_3.2.0-3_all.deb ## mingw-w64-i686-dev_3.2.0-3_all.deb ## mingw-w64-i686-dev_3.2.0-3_all.deb ## mingw-w64-i686-dev_3.2.0-3_all.deb ## $DPKG -i mingw-w64-common_3.2.0-3_all.deb $DPKG -i mingw-w64-i686-dev_3.2.0-3_all.deb $ aptitude install gcc-mingw-w64-i686 $ aptitude install g++-mingw-w64-i686 $ aptitude install gfortran-mingw-w64-i686 $ aptitude install mingw-w64-toolsCopy the code
- configure: error: You need 32-bits luac when using lua from contrib
/ VLC /configure: #as_fn_error $? $aptitude install lua5.2:i386 "You nedd 32-bits luac when using lua from contrib." ## 为 $aptitude install lua5.2:i386Copy the code
- libavutil versions 55 and later are not supported
# # # # : refer to the original https://blog.csdn.net/freeman1975/article/details/50572374 to: $aptitude install -y libdbus-1-dev lua5.1 liblua5.1-dev libmad0-dev libavcodec-dev libavformat-dev libswscale-dev libpostproc-dev liba52-dev libxcb1-dev libxcb-shm0-dev libxcb-xv0-dev libx11-xcb-dev libgl1-mesa-dev libqt4-dev Libgcrypt11 - dev # # again: $ ./configure --disable-lua --disable-mad --disable-avcodec --disable-avformat --disable-swscale --disable-postproc --disable-a52 --disable-mkv ##Copy the code
- configure: error: Package requirements (xcb) were not met
$sudo aptitude install libxcb-composite0-dev ## No package 'XCB' found ## 解 错 : $sudo aptitude install libxcb-composite0-devCopy the code
- No package ‘alsa’ found. Alsa -lib 1.0.24 or later required
$sudo apt-get install libalsa-ocaml-dev $sudo apt-get install libalsa-ocaml-devCopy the code