How to build and develop Natron on Windows x64 (8.1/10)

NatronBuild

Since this has been requested several times, here’s a tutorial :slight_smile: There might be some typos etc, will fix when notified

So, you want to build and/or develop Natron on Windows? Let’s start.

Setup a MSYS2 environment

The first thing that is needed is MSYS2, note that we use a specific snapshot and custom packages. You must use the exact version and commands described or you may end up with a non-functional SDK installation.

  • Download and extract msys2-base-x86_64-20180531.tar.xz
  • Move the extracted msys64 folder to C:\msys64-20180531 (Other locations are untested)
  • Run C:\msys64-20180531\mingw64.exe (this will trigger a setup script, wait until done)
  • When prompted close the MSYS2 window

Now start C:\msys64-20180531\mingw64.exe, then run the following commands:

$ sed -i 's/SigLevel    = Required DatabaseOptional/SigLevel = Never/' /etc/pacman.conf
$ echo "Server = https://downloads.sourceforge.net/project/openfx-arena/MINGW-packages/mingw64" > /etc/pacman.d/mirrorlist.mingw64
$ echo "Server = https://downloads.sourceforge.net/project/openfx-arena/MINGW-packages/msys" > /etc/pacman.d/mirrorlist.msys

This will setup a custom MSYS2 repository used by Natron, you only need to do this once. Now install the SDK:

$ pacman -Syu natron-sdk

This will install everything required to build Natron, the plug-ins and the SDK (if you need to rebuild or update anything).

You now have a working Natron SDK installation. Launch C:\msys64-20180531\mingw64.exe when you need to build anything.

Setup a development environment (Qt Creator)

This part will document how to setup Qt Creator for building and developing Natron.

Qt debug-and-release

The default installation of Qt is release mode, to get a debug-and-release version download mingw-w64-x86_64-qt4-4.8.7-8-any.pkg.tar.xz, launch C:\msys64-20180531\mingw64.exe and install it.

pacman -U /path/to/mingw-w64-x86_64-qt4-4.8.7-8-any.pkg.tar.xz

Setup

Start Qt Creator and go to Tools=>Options.

Debuggers

Go to the Kits menu and select Debuggers, then add a new.

The path is C:\msys64-20180531\mingw64\bin\gdb.exe.

Compilers

Go to the Kits menu and select Compilers, then add a new (MINGW=>C).

The path is C:\msys64-20180531\mingw64\bin\cc.exe.

Go to the Kits menu and select Compilers, then add a new (MINGW=>C++).

The path is C:\msys64-20180531\mingw64\bin\c++.exe.

Qt

Go to the Kits menu and select Qt Versions, then add a new.

The path is C:\msys64-20180531\mingw64\bin\qmake.exe.

Kits

Go to the Kits menu and select Kits, then add a new.

Now select the GDB, GCC and Qt versions added previous.

Project

Clone the Natron source then start Qt Creator.

git clone https://github.com/NatronGitHub/Natron
cd Natron
git submodule update -i --recursive
wget https://github.com/NatronGitHub/OpenColorIO-Configs/archive/Natron-v2.1.tar.gz
tar xvf Natron-v2.1.tar.gz
mv OpenColorIO-Configs-Natron-v2.1 OpenColorIO-Configs

Open Project.pro from the Natron git source folder and select the custom kit added previous. When done go to the Projects tab and add a new environment variable PYTHONHOME with the value C:\msys64-20180531\mingw64.

That’s it! You should now be able to build and run release and debug versions of Natron directly from Qt Creator.

Setup a CI environment

With a working MSYS2 installation launch C:\msys64-20180531\mingw64.exe and clone the build tools:

git clone https://github.com/NatronGitHub/Natron NatronCI

Now create a build script:

#!/bin/bash
# Build Natron Windows Snapshot
#
# Unit tests may freeze/stall several times, when/if that happens run : NR=`ps aux | grep NatronRenderer | awk '{print $1}'` && kill -9 $NR
#
export WORKSPACE=$HOME/NatronCI-snapshot
export UNIT_TESTS=true
export BUILD_NAME=snapshots
export BUILD_NUMBER=RB-2.3
export GIT_URL=https://github.com/NatronGitHub/Natron.git
export SNAPSHOT_BRANCH=RB-2.3
export GIT_BRANCH=RB-2.3
export NATRON_LICENSE=GPL
export NATRON_DEV_STATUS=SNAPSHOT
export NATRON_BUILD_NUMBER=1
export COMPILE_TYPE=relwithdebinfo
export BITS=64
export DISABLE_BREAKPAD=1
export DISABLE_PORTABLE_ARCHIVE=0
export REMOTE_URL=NO_URL
export REMOTE_USER=NO_USER
export REMOTE_PREFIX=NO_PREFIX
export MKJOBS=4
export LOCALAPPDATA="/c/Users/USERNAME/AppData/Local"
export MSYSTEM=MINGW64
export NOUPDATE=1
export GIT_URL_IS_NATRON=1

if [ ! -d "$WORKSPACE" ]; then
    mkdir -p "$WORKSPACE"
fi

./launchBuildMain.sh

and save to $HOME/NatronCI/tools/jenkins/build-snapshot.sh. Remember to change LOCALAPPDATA to match your username, and MKJOBS to match your CPU. You can disable unit tests with UNIT_TESTS=false.

Now run the script (active internet connection needed):

cd $HOME/NatronCI/tools/jenkins
bash build-snapshot.sh

The result will be in $HOME/NatronCI-snapshot.

This was just an example, see launchBuildMain.sh for more information/options.

4 Likes

I don’t use QtCreator, I prefer CLion. I’m still working on getting a recipe built for CLion, but I’m definitely able to launch my local Natron builds directly from my development environment.

I launch Natron from the MSYS shell, like this:

Michael@zero MINGW64 /d/sandbox/natron/App
$ release/Natron.exe

I’m specifically running the release/Natron.exe command from the App folder inside my Natron repository.

I also pulled in the Plugins and Resources from a 2.3.15 release build and put them in the App folder:

Michael@zero MINGW64 /d/sandbox/natron/App
$ ls -l
total 48
-rw-r--r-- 1 Michael None  2943 Sep 25 11:32 App.pro
drwxr-xr-x 1 Michael None     0 Sep 25 11:56 debug
-rw-r--r-- 1 Michael None  8051 Sep 25 11:56 Makefile
-rw-r--r-- 1 Michael None 10633 Sep 25 11:56 Makefile.Debug
-rw-r--r-- 1 Michael None 10931 Sep 25 11:56 Makefile.Release
-rw-r--r-- 1 Michael None  5263 Sep 25 11:32 NatronApp_main.cpp
-rw-r--r-- 1 Michael None  2165 Sep 25 11:32 NatronInfo.plist.in
drwxr-xr-x 1 Michael None     0 Sep 25 12:02 Plugins
drwxr-xr-x 1 Michael None     0 Sep 27 14:01 release
drwxr-xr-x 1 Michael None     0 Sep 25 12:04 Resources

I’m planning on looking into putting together a PR so that the Plugins and Resources locations can be specified from the command-line and/or through environment variables (if that’s not already an option).

I also ended up having to add the bin folder from my installed release build of 2.3.15 last in my PATH, to clear up a few other missing DLLs (most image libraries). I may just need additional packages in my MSYS environment to clear this up.

But this got me to a place where I was able to open some compositing projects I’m working on. Maybe this will help?

Plugins and OCIO location have settings in preferences.

1 Like

Nice. I will do another try to get my building working following these instructions, as last time I got stuck and couldn’t figure out what to do.

Hopefully I am not spamming these build threads too much, but I tried with these instructions which were very clear and I failed. When I tried to build with QT, in /App/Debug/ -folder Natron.exe file was created, but during build process was lot of warnings and errors and then the Natron.exe disappeared.

I think I got all other instructed steps correct, but for some reason debugger is not recognised. See attached image. There might be other issue as well to cause build fail, as I couldn’t get building done with old instructions either (without QT).

Notice

The repository url has changed:

echo "Server = https://downloads.sourceforge.net/project/natron/MINGW-packages/mingw64" > /etc/pacman.d/mirrorlist.mingw64
echo "Server = https://downloads.sourceforge.net/project/natron/MINGW-packages/msys" > /etc/pacman.d/mirrorlist.msys
pacman -Syu

I don’t seem to be able to edit my original post anymore(?)

After a certain amount of time, it locks the post to try preserve the thread’s history.

We can make the original post a wiki post, so you can update it (I think).

This documentation has now been moved to Natron/README.md at RB-2.4 · NatronGitHub/Natron · GitHub