Tag Archives: vector graphics

Compiling Rive-Tizen (Rive and ThorVG) on windows

I’ve been an avid Flash and Actionscript developer for a long time. With the decline of Flash there was nothing really suitable to replace the scalable vector graphics that was the major benefit of Flash. But now, along comes Rive to the rescue, providing a fantastic, open, vector creation tool and format, and ThorVG, providing a small, powerful vector drawing engine with no external dependencies.

Both of these projects are still in early stages of active development, but both look very promising, and have dedicated and passionate contributors behind them.

Rive-Tizen is a small project that connects the two, allowing you to render Rive animations using ThorVG. Based on my experimentation, I’ve jotted down some tips for compiling the rive-tizen project on windows using Visual Studio. Note that you’ll get the best results using the clang-cl compiler rather than the built-in msvc compiler.

I run Visual Studio 2019 Community Edition on Windows 11, but it may work for other combinations as well.

Install prerequisite tools (ninja, meson, clang-cl)
  • Install clang-cl as a Visual Studio component using these instructions
  • Install both meson and ninja build systems. There is an msi installer that does both provided by meson.
Clone and prepare the code
  • Clone the rive-tizen repo to your machine
    • Install the submodule dependency (rive) using your favorite git tool (I use GitKraken. and it is awesome), or use the git command line and enter git submodule update --init --recursive
  • Clone the thorvg repo to your machine
Edit the rive-tizen meson build file

There are some edits required to rive-tizen/meson.build to support windows. Here is what I did:

  • Add the compiler flag _USE_MATH_DEFINES so that math related defines like M_PI are available.
  • Change how meson looks for the thorvg dependency by specifying the path to the ThorVG source files instead. Make sure you change the path to match where you cloned the thorvg repo!

This is what meson.build file looks like now. Be careful, depending on when you read this it may be out of date, so make sure to just take the changes you need.

project('rive_tizen',
    'cpp',
    default_options : ['cpp_std=c++17'],
    version : '0.1.0',
    license : 'MIT')

add_project_arguments('-DRIVE_FILE_DIR="@0@/example/resources/"'.format(meson.current_source_dir()), language : 'cpp')

# changes start
thorvg_dep = dependency('thorvg', required : false)
if thorvg_dep.found() != true
    thorvg_dep = declare_dependency(include_directories : include_directories('../thorvg/inc'))
    if thorvg_dep.found() != true
        error('ThorVG dependency not found. Looking for ../thorvg')
    endif
endif
if host_machine.system() == 'windows'
    add_project_arguments('-D_USE_MATH_DEFINES', language: 'cpp')
endif
# changes end

# ... rest of file
Run and configure meson
  • This works best using the VS command prompt, so open a visual studio command prompt (instructions).
    • I do this by typing command in the windows search bar, and selecting the result called x64 Native Tools Command Prompt for VS 2019.
  • Change directory to rive-tizen folder. For example, mine is here:
    cd C:\Projects\rive-tizen
  • Change the compiler to clang-cl
    set CXX=clang++
  • Run meson
    meson build
  • Enter the build folder
    cd build
  • Change some configuration options to build a static lib and specify that it’s a release build. The last option suppresses a warning about “non-virtual destructor”. because there are a LOT of these.
meson configure -Ddefault_library=static -Dbuildtype=release -Doptimization=2 -Dcpp_args=['-Wno-non-virtual-dtor']
  • Hint: There are many more things you can tweak. To see all the config options available, type
    meson configure
Compile the static library
  • Still in the command prompt, run ninja
    ninja -C .
  • Now you should have a compiled static library!