Build QtAV (original) (raw)

Uninstall QtAV SDK before building to avoid header files confliction. Run sdk_uninstall.bat/sh under your build dir

Shadow build is recommended (required for mac build).

0. Prerequisites

git clone https://github.com/wang-bin/QtAV.git  
cd QtAV && git submodule update --init  

For windows, download http://sourceforge.net/projects/qtav/files/depends/QtAV-depends-windows-x86%2Bx64.7z/download and using bin, include, lib in the package is enough to build.

Other requirements are:

sudo apt-get install libopenal-dev libpulse-dev libva-dev libxv-dev libass-dev libegl1-mesa-dev  

You may have to install VA-API drivers to make VA-API available at runtime

1. Setup the environment

You MUST let your compiler know where FFmpeg headers and libraries are. Otherwise you will get an error when running qmake. If they are already be where they should be, for example you install from apt on ubunt, just skip this step.

Choose one of the following methods.

It's the simplest and best way. Qt include and lib dir are always searched in QtAV. It should work for all platforms, including android, iOS, WinRT and meego etc.

Take Windows for example, Qt is installed in C:\Qt\5.7\msvc2015_64\ . Goto that dir and put ffmpeg headers to include\, libs to lib\

Extract ffmpeg to QtAV source dir. add 2 lines in .qmake.conf

INCLUDEPATH += <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow></mrow><annotation encoding="application/x-tex"></annotation></semantics></math></span><span class="katex-html" aria-hidden="true"></span></span>PWD/ffmpeg/include
LIBS += -L$$PWD/ffmpeg/lib

(NOT Recommended)Use Environment Vars

set INCLUDE=ffmpeg_path\include;openal_path\include;%INCLUDE%  
set LIB=ffmpeg_path\lib;openal_path\lib;%LIB%  
export CPATH=ffmpeg_path/include:openal_path/include:$CPATH  
export LIBRARY_PATH=ffmpeg_path/lib:openal_path/lib:$LIBRARY_PATH  
export LD_LIBRARY_PATH=ffmpeg_path/lib:openal_path/lib:$LD_LIBRARY_PATH  

windows cmd.exe environment without UNIX Shell command line

set CPATH=ffmpeg_path\include;openal_path\include;%CPATH%  
set LIBRARY_PATH=ffmpeg_path\lib;openal_path\lib;%LIBRARY_PATH%  
export CPATH=/usr/local/Cellar/ffmpeg/[VERSION]/include:$CPATH  
export LIBRARY_PATH=/usr/local/Cellar/ffmpeg/[VERSION]/lib:$LIBRARY_PATH  
export DYLD_LIBRARY_PATH=/usr/local/Cellar/ffmpeg/[VERSION]/lib:$DYLD_LIBRARY_PATH  
~/Qt/5.7/clang_64/bin/qmake [QtAV Repo Directory]/QtAV.pro  

2. Build in QtCreator or command line

mkdir your_build_dir  
cd your_build_dir  
qmake QtAV_source_dir/QtAV.pro  
make -j4  

It's strongly recommended not to build in source dir(especially OSX).
qmake will check the required libraries to make sure they can be found by compiler.
Then qmake will create a cache file .qmake.cache in your build dir. Cache file stores the dependencies check results, for example, whether openal is available. If you want to recheck, you can either delete .qmake.cache and run qmake again, or run

qmake QtAV_source_dir/QtAV.pro -r "CONFIG+=recheck"  

WARNING: If you are in windows mingw with sh.exe environment, you may need run qmake twice. I have not found out the reason behind this phenomenon.


CMake Build

QtAV 1.12 supports cmake. cmake + ninja can reduce build time. You have to set QTDIR to the installed qt path, otherwise cmake will find Qt5 in system default dirs.

cmake -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DQTDIR=C:\Qt\5.8\msvc2015 qtav_src_dir
ninja
ninja install

Visual Studio/MSBuild

I don't put any vs project file in QtAV, because it's easy to create by qmake.

Open a correct VS Prompt, for example, to build UWP for mobile, open VS2015 prompt for arm. Then run command there

%QTDIR%\bin\qmake -r -tp vc QtAV.pro

Where QTDIR is the corresponding Qt version directory, for example D:\Qt\5.7\winphone_arm for windows phone 8.1. Then sln and vcxproj(vcproj) files will be created. Run msbuild /m to build the projects (/m option will break the build since qt5.7, just remove it). You can also open QtAV.sln in your Visual Studio to Compile it.

Another solution is using Qt vs plugin. It will help you to load qmake projects(not tested).

QtCreator With MSVC

QtCreator will detect VC compiler if it is installed. So it's easy to build in QtCreator

Build for Android on Windows

You may get qmake error libavutil is required, but compiler can not find it. That's because mingw32-make.exe can not be found in the config test step. An workaround is put your mingw32-make.exe to one of %PATH% dirs

Build Debian Packages

run

in QtAV source tree

QtAV >=1.4.2 supports linking to static ffmpeg and openal libs. It's disabled by default. To enable it, add

CONFIG += static_ffmpeg static_openal

in QtAV/.qmake.confforQt5orQtAV/.qmake.conf for Qt5 or QtAV/.qmake.confforQt5orQtAV_BUILD_DIR/.qmake.cache

Ubuntu 12.04 Support

If QtAV, FFmpeg and OpenAL are built on newer OS, some symbols will not be found on 12.04. For example, clock_gettime is in both librt and glibc2.17, we must force the linker link against librt because 12.04 glibc does not have that symbol. add

to .qmake.conf or .qmake.cache

CI

You can read the build log to see how they work.

Build Error

Make sure ffmpeg headers and libs can be found by compiler. Read config.log in build dir for details.