Compiling Aseprite for Linux

This post details my experience compiling Aseprite (the most popular pixelart editor) for Ubuntu. It was poorly documented, so I aim to be as concise as possible so those reading have no trouble.

That being said, this guide is for compiling Aseprite on Linux, not Windows. Windows has a few extra steps, and I'll link a handy guide here.

Compiling Tools

On Linux, Aseprite requires the following packages:

g++ cmake ninja-build libx11-dev libxcursor-dev libxi-dev libgl1-mesa-dev libfontconfig1-dev

Install them with your package manager of choice. For example, on Ubuntu:

sudo apt-get install -y g++ cmake ninja-build libx11-dev libxcursor-dev libxi-dev libgl1-mesa-dev libfontconfig1-dev

You also need CMake version 3.14 or higher. To check, run:

cmake --version

Next, the Ninja build system is needed. Here are a few installation methods by distro:

Arch: pacman -S ninja

Debian/Ubuntu: apt-get install ninja-build

Fedora: dnf install ninja-build

Skia

Last but not least, you will need both depot_tools and the Skia graphics library. There are two methods, compiling Skia from source or downloading a prebuilt binary.

Compiling From Source

The following script creates a dep folder in your root directory to store both packages in. Note that compiling Skia will take a while, depending on the machine.

mkdir $HOME/deps
cd $HOME/deps
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
git clone -b aseprite-m81 https://github.com/aseprite/skia.git
export PATH="${PWD}/depot_tools:${PATH}"
cd skia
python tools/git-sync-deps
gn gen out/Release-x64 --args="is_debug=false is_official_build=true skia_use_system_expat=false skia_use_system_icu=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_zlib=false"
ninja -C out/Release-x64 skia modules

Prebuilt Binary

Before downloading anything, run:

mkdir ~/deps ~/deps/skia

This ensures the binary is easily accessible by the aseprite install script detailed later in the article. Feel free to change the path, but remember to change the directory in the install script as well.

Then, go ahead and download the release. Make sure the branch is Skia-m81. After downloading, extract the contents into the deps/skia directory.

Compiling Aseprite

Now, you have to pull the official GitHub repository for Aseprite.

git clone --recursive https://github.com/aseprite/aseprite.git

The line above will create a folder called aseprite in the directory you ran the command in. I recommend creating it in your root directory, but it shouldn't matter where.

For future reference, to update Aseprite, run the following commands:

cd aseprite
git pull
git submodule update --init --recursive

Next, you have to create a build directory to store compile output and the generated Aseprite binary. Modify the first command below if you cloned Aseprite in a different location.

cd ~/aseprite
mkdir build
cd build

There are only a few more commands to get Aseprite working! Next up is compilation with CMake. Remember, if you decided to install Skia in another location, replace $HOME/deps/skia with that path.

cmake \
  -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  -DLAF_BACKEND=skia \
  -DSKIA_DIR=$HOME/deps/skia \
  -DSKIA_LIBRARY_DIR=$HOME/deps/skia/out/Release-x64 \
  -G Ninja \
  ..

Finally, run this to compile the Aseprite binary:

ninja aseprite

There you have it! After the compilation finishes, navigate to aseprite/build/bin and you should see the aseprite file. You can run it in terminal with:

./aseprite

However, for ease of access, you may want to launch it from the applications menu or the dock. The next section explains the process of creating a desktop file to do this.

Installing Aseprite Globally

To install Aseprite system-wide, you need to make use of the .desktop file format. For example, this is my entry for Aseprite, installed in /usr/share/applications:

aseprite.desktop

[Desktop Entry]
X-AppInstall-Package=aseprite
X-AppInstall-Popcon=0
X-AppInstall-Section=universe

Name=ASEPRITE
Comment=Sprite Editor
Exec=aseprite
Icon=aseprite
Terminal=false
Type=Application
Categories=Graphics;2DGraphics;RasterGraphics;

X-Ubuntu-Gettext-Domain=app-install-data

As arguments for this file differ based on distribution, we'll use the alacarte package. This program is available in most package repositories, like the AUR and apt.

To install on Ubuntu, run:

sudo apt-get install -y alacarte

After installation, run the command alacarte in a terminal, and a GUI should pop up. In the left sidebar, click "Graphics".

From here, the "New Item" button in the right sidebar should be clickable. A new GUI should pop up, and you can fill in details such as the name of the program (Aseprite), and the command to be run.

For the command, click "Browse", navigate to ~/aseprite/build/bin/ (or wherever you installed it), and click the aseprite binary. Once you close the file chooser, the input prompt section should be filled with a command ending with "aseprite". Finally, add a comment and an icon (if you want to), and save.

If you want the icon to be the official Aseprite icon, navigate to ~/aseprite/data/icons, which has a few images to choose from.

Done!

Aseprite should now be accessible when searching the applications menu. It should also be pinnable to the dock.

I hope this article helped, and good luck on your pixelart journey!


Permalink: https://blog.rbansal.dev/aseprite-for-linux/