Skip to content

Building

TianZer edited this page Aug 6, 2022 · 12 revisions

Dependent Libs

Building on Windows

Compiler: MSVC (recommend VS2019), Clang (Mingw64 are not fully support C++17 filesystem yet)

Step 1:

Use CMake to generate the project, all libs will be auto found by CMake except VapourSynth, you need to specify it manually.

Step 2:

  • For MSVC, remember to change generating method form debug to release, and compile it.
  • For clang, just make it.

Step 3:

Get your binary file in bin folder.

Building on Linux

Prerequisites

  • CMake 3.0 or higher is required
  • OpenCV, OpenCL
  • Compiler: [G++](recommend g++8 or higher), Clang
  • boost filesystem (optional)
  • Qttools5 (qttools5-dev and qttools5-dev-tools) (Can be ignored for cli build)

Building

Step 1:

Use CMake to generate the project

cmake ..

Step 2:

Just make it.

Step 3:

Get your binary files in bin folder.

Take building CLI in Ubuntu as an example

Tested on Ubuntu 18.04 with g++ 8.4.0

#install dependency
sudo apt install libopencv-dev ocl-icd-opencl-dev cmake
#clone repo
git clone https://github.com/TianZerL/Anime4KCPP.git
#cmake it
cd Anime4KCPP && mkdir build && cd build && cmake ..
#make it
make
#check it
cd bin && ./Anime4KCPP_CLI -V

Building on macOS (from NightMachinary)

We need to install all the aforementioned dependencies via brew (excpet OpenCL which is provided by Apple):

brew install opencv qt ffmpeg openh264 cmake

For brew's qt to work you need to set these (see latest instructions by brew info qt):

# If you need to have qt first in your PATH run:
  echo 'export PATH="/usr/local/opt/qt/bin:$PATH"' >> ~/.zshrc

# For compilers to find qt you may need to set:
  export LDFLAGS="-L/usr/local/opt/qt/lib"
  export CPPFLAGS="-I/usr/local/opt/qt/include"

# For pkg-config to find qt you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/qt/lib/pkgconfig"

Now we need to fix macOS libomp problem (copied from here):

  • Install LLVM with openmp and libomp with brew

     brew update
     brew install llvm libomp
  • Run CMake with the new compilers

     # in repo's root
     cmake -DCMAKE_C_COMPILER="/usr/local/opt/llvm/bin/clang" -DCMAKE_CXX_COMPILER="/usr/local/opt/llvm/bin/clang++" .

Now we just run make. The binaries should have been installed to ./bin/.

Note that Apple has deprecated OpenCL (to force its own proprietary Metal API), and may remove support for it in later versions.

Build Android Version

  • Create a new project in your Android studio
  • Copy all of the files of Android to your project
  • Copy Anime4KCore folder to app/src/main/cpp/
  • Set your libs (OpenCV OpenCL for Android) path in app/src/main/cpp/CMakeLists.txt
  • Build

NOTICE: You must build the OpenCV with FFmpeg for Android by yourself, otherwise the video processing will be faulted.