-
Notifications
You must be signed in to change notification settings - Fork 376
Compile YUView
If you want to compile YUView from source, here is a short how-to. We use qmake for the project so there is actually not much to consider when compiling the sources. Qt should take care of everything necessary to generate the executable. However, here is a short introduction for the supported platforms.
ℹ️ In-tree builds are discouraged because they just result in chaos when the build files and source files are mixed in the directories. So please create a folder to compile in. Usually I create a
build
folder in the YUView sources root folder and build in there. But any empty folder anywhere else will also work.
You will require a C++ 14 compiler as well as Qt. The minimum Qt version that we test is 5.9.5. We are building YUView in Github actions on Windows, Ubuntu and MacOs. Please check out the workflow file in the repository to see how exactly we build YUView. The file is in .github/workflows
.
On windows you will have to install Qt and a compiler. We use the Visual Studio compiler. But also the MinGW compiler should work. If you installed this you can just compile using the YUView.pro file. So, assuming you are in the YUView folder that you checked out:
mkdir build
cd build
C:\Qt\somewhere\qtbase\bin\qmake.exe ..\YUView.pro
Now the build files should be created. Start the build by executing one of these commands:
nmake # For visual studio
jom # The much faster parallel nmake alternative (must be downloaded separately)
make # For MinGW
You can also open the YUView.pro file in the QtCreator. Here you will have to configure the project to use a compiler (Qt should auto detect the Visual Studio and MinGW compilers) and hit the build button.
One more option is to let qmake create a visual studio project file for you:
mkdir build
cd build
qmake.exe -tp vc -r ../YUView.pro
Open the 2 projects YUView and YUViewLib in Visual Studio, open the property settings of theses 2 projects respectively, switch to configuration property - general, select ISO C++17 standard (/std:c++17) for the C++ language standard, selects ISO C17 (2018) standard (/std:c17) for C language stardard. Then switch to C/C++ - output file of the YUViewLib project, and set the object file name to "$(IntDir)%(RelativeDir)".
You can then open it in Visual Studio or alternatively build using msbuild
msbuild /p:Configuration=Release
If you are using visual studio code you can compile YUView in there as well. The following requirements must be met:
- Installed Qt
- Installed C++ build environment (either install Visual Studio or just the Build environment)
- Make sure
"terminal.integrated.automationShell.windows": "cmd.exe"
is set in the config so that this is not called in powershell. If this does not work, try selecting the default shell (Ctrl+Shift+P and typedefault shell
).
Use the following task.json
entry to compile using qmake
and nmake
. Correct the paths to your needs.
"tasks": [
{
"label": "Qmake debug",
"type": "shell",
"windows":{
"command": "call \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Auxiliary\\Build\\vcvars64.bat\" && \"C:\\Qt\\5.12.6\\msvc2017_64\\bin\\qmake.exe\" CONFIG+=debug",
},
"options": {
"cwd": "${workspaceFolder}/build"
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Build",
"type": "shell",
"windows":{
"command": "call \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Auxiliary\\Build\\vcvars64.bat\" && nmake",
},
"options": {
"cwd": "${workspaceFolder}/build"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
The following launch.json
configuration uses a qt5 native file to decorate Qt types while debugging:
"configurations": [
{
"name": "(Windows) Launch",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/build/debug/YUView.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"visualizerFile": "${workspaceFolder}/.vscode/qt5.natvis"
}
On MacOS, compilation is simple as well. You need to install XCode (from the app store) as well as Qt (from the Qt Download page or install it through homebrew). Now you can open the YUView.pro file using the QtCreator, hit configure and build YUView. Alternatively, compilation also works from the command line. So, assuming you are in the YUView folder that you checked out:
mkdir build
cd build
qmake ../YUView.pro
make -j 8
On Linux systems compiling is similarly easy. You have to install Qt and a compiler. On most Linux distributions the gcc compiler is installed with the default packages so there is no action needed. If you don't have a compiler installed then it depends a bit on your distribution how to install it. But probably you have a package manager that can do it for you.
Unfortunately, it depends a little on your distribution how to obtain Qt. Here are some hints for distributions that we tested:
-
Ubuntu 18: Install Qt using apt:
sudo apt install qt5-default
-
Ubuntu 16: Install Qt using apt:
sudo apt install qt5-default libqt5opengl5-dev
-
Ubuntu 14: Unfortunately, Qt5 is not present in the package repository for older Ubuntu versions. In Ubuntu 14.x for example, qt5 is not in the repositories. One option is to go to the qt homepage and download the latest qt version from here. Start the installer and select the latest qt-gcc version. A second option is to install qt from the following repositories:
sudo add-apt-repository ppa:beineri/opt-qt571-trusty -y
,sudo apt-get update -qq
,sudo apt-get install -qq qt57base; source /opt/qt57/bin/qt57-env.sh
- Arch Linux: On Arch, just use pacman to update the packages/install Qt. If you selected the default installation, Qt should already be installed.
When Qt is installed, you can use qmake or the QtCreator to build YUView. On the command line you can just use qmake
and then make
. So, assuming you are in the YUView folder that you checked out:
mkdir build
cd build
qmake ../YUView.pro
make -j 8
Using the creator, just open the YUView.pro file, configure the project to use a compiler (Qt should auto detect gcc) and hit the build button. Additionally, you can install the program running sudo make install
. This will also install a desktop entry.
If you get the error cannot find -lGL
the openGL libraries were not found. These libraries are required by Qt. You will have to install these for your linux distribution. However, the libGL might already be on your system, but the compiler could just not find it. You can try locate libGL
to see if the library is already installed. If yes, you can just link it to a library search path like /usr/lib
. For example on Ubuntu 15.4 this works:
sudo ln -s /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 /usr/lib/libGL.so
If you want to compile a debug version of YUView, you can run qmake with the CONFIG+=debug
parameter.
If you have multiple compilers you can specify a mkspec
to tell qmake which one to use. On Ubuntu the path to the mkspecs
is /usr/lib/x86_64-linux-gnu/qt5/mkspecs/
but this may differ for your system. E.g. to use the clang compiler on linux do:
qmake -spec linux-clang ../YUView.pro