Skip to content

Instantly share code, notes, and snippets.

@ryan-robeson
Last active September 1, 2024 19:31
Show Gist options
  • Save ryan-robeson/5841f712ff23c910bbbfac793c16bfad to your computer and use it in GitHub Desktop.
Save ryan-robeson/5841f712ff23c910bbbfac793c16bfad to your computer and use it in GitHub Desktop.
Building Resynthesizer for GIMP 2.10.10 on macOS

Building Resynthesizer for GIMP 2.10.10 on macOS - V2

Feedback is welcome and appreciated.

  • If you'd prefer to do things by hand check out Version 1 of this guide.

The following documents the steps I took to compile the latest version of Resynthesizer on macOS Sierra (10.12.6) for GIMP 2.10.10.

Homebrew was used to fulfill as many dependencies as possible.

After writing Version 1, I decided to make a Tap available which contains libgimp2.0. This should simplify the process of compiling GIMP plugins on macOS.

This guide assumes you'll be running Resynthesizer under GIMP 2.10.10 installed with brew cask install gimp.

Overview

  1. Setup build directory
  2. Acquire sources
  3. Install dependencies
  4. Compile Resynthesizer
  5. Install Resynthesizer

1 - Setup build directory

# I setup my build directory as recommended by [this howto](https://www.GIMP.org/source/howtos/GIMP-git-build.html) on GIMP.org.
# It allows us to keep things contained.

# You can put your build directory wherever is convenient.
# However, it's best if it's a new, empty directory unless you know what you're doing.

# We will assume that our build directory is '~/Code/build-gimp-plugins'.
# Let's refer to this directory with a variable
PREFIX=~/Code/build-gimp-plugins

# We need to create this directory if it does not exist.
mkdir -p $PREFIX

# We also need to create a couple other important directories.
mkdir -p $PREFIX/share # This is where config.site should be placed.
mkdir -p $PREFIX/bin

# In my case, I had installed perl from Homebrew at some point in the past.
# It did not come with a module Resynthesizer needed to compile, so rather than install
# that module which may have worked, I symlinked the system perl into $PREFIX/bin
# to make sure it was used instead of the Homebrew version.
# You may or may not have this issue.
# ln -s /usr/bin/perl $PREFIX/bin/perl

# Make sure you've placed 'config.site' in $PREFIX/share

2 - Acquire sources

# Now we're going to get the Resynthesizer source.
# Make sure we're in our build directory
cd $PREFIX

# Resynthesizer
git clone git://github.com/bootchk/resynthesizer.git

# Now's the time to `git checkout` a branch or tag if you don't want to compile
# Resynthesizer's latest code.

3 - Install dependencies

# Resynthesizer needs libgimp2.0 to compile
brew tap ryan-robeson/gimp
brew install libgimp2.0

4 - Compile Resynthesizer

# We're on the home stretch now
cd resynthesizer

# NOTE: @SimplyTheOther found the following change to be unnecessary on their system.
#       You should be able to skip editing the Resynthesizer source. I'm going to leave
#       the info here for now just in case.
#
# ** You can likely skip this ** #
# In order to get Resynthesizer to compile on macOS, I had to make a small change in the source.
# Open lib/engineTypes.h in your editor of choice.
# At the end of the file is the definition for swap_vector_elements.
# Add 'static' in front of 'inline void'.
# Save and exit.
# Without this change I was getting a 'symbol(s) not found' error.
# I got the idea to add 'static' from https://stackoverflow.com/a/19069107
# I do not know what the ramifications of this change are, I only know that it compiled and seems to work.
# ** end skip ** #

./autogen.sh --prefix=$PREFIX
make
# I don't believe `make install` will do what we want here, so skip it.

# If there are no errors, proceed to the next step.

5 - Install Resynthesizer

# You could copy the plugin files to one of GIMP's default plugin directories, 
# but I decided to put them in their own directory and tell GIMP about it.

mkdir plug-ins
cp src/resynthesizer/resynthesizer plug-ins/
cp src/resynthesizer-gui/resynthesizer_gui plug-ins/
cp PluginScripts/*.py plug-ins/
chmod a+x plug-ins/*.py

# Now open your system's copy of GIMP (installed by Homebrew Cask in my case),
# open Preferences, expand the folders dropdown, select Plug-ins, and add the plug-ins folder
# we just created to the list.
# Click OK. Then restart GIMP.

# Filters > Enhance > Heal Selection and several others should now be available.
# This is an example config.site for building plugins manually after
# installing libgimp2.0.
# It should be placed in $PREFIX/share/
# It may need to be adjusted based on your plugin's dependencies.
# A convenient reference for our Homebrew install dir
: ${HOMEBREW_ROOT:=$(brew --prefix)}
export PATH="$PREFIX/bin:$HOMEBREW_ROOT/opt/gettext/bin:$PATH"
export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$HOMEBREW_ROOT/lib/pkgconfig:$HOMEBREW_ROOT/opt/gegl/lib/pkgconfig:$HOMEBREW_ROOT/opt/libffi/lib/pkgconfig:$PKG_CONFIG_PATH"
export LD_LIBRARY_PATH="$PREFIX/lib:$LD_LIBRARY_PATH"
export ACLOCAL_FLAGS="-I $PREFIX/share/aclocal -I $HOMEBREW_ROOT/opt/gettext/share/aclocal/ -I $HOMEBREW_ROOT/share/aclocal $ACLOCAL_FLAGS"
export LDFLAGS="-L$HOMEBREW_ROOT/opt/gettext/lib -L$HOMEBREW_ROOT/lib $LDFLAGS"
export CPPFLAGS="-I$HOMEBREW_ROOT/opt/gettext/include -I$HOMEBREW_ROOT/include $CPPFLAGS"
@rljacobson
Copy link

I consistently get: Error: [email protected]: undefined method 'cellar' for #<BottleSpecification:0x0000000147d15d10>

I am getting the same error.

@davegoldin
Copy link

I am on Sonoma 14.1.2 and Homebrew 4.1.25 on Apple Silicon. Following these two commands – brew tap ryan-robeson/gimp and brew install [email protected] – I am getting the same error as prior two posters. @ryan-robeson Any guidance you can provide? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment