Skip to content

Instantly share code, notes, and snippets.

@AndersBillLinden
Last active June 5, 2018 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndersBillLinden/dc6ad50bd0e0a15b89f1eca0b57cb8a6 to your computer and use it in GitHub Desktop.
Save AndersBillLinden/dc6ad50bd0e0a15b89f1eca0b57cb8a6 to your computer and use it in GitHub Desktop.
Setting up gimp on windows

Building gimp on Windows

Following instructions on https://wiki.gimp.org/wiki/Hacking:Building/Windows on windows 10 pro, build 16299

  1. Surfing to www.msys2.org

  2. Downloading msys2-x86_64-20180531.exe by clicking link.

  3. Checking the sha-256 checksum of the file so its 3b233de38cb0393b40617654409369e025b5e6262d3ad60dbd6be33b4eeb8e7b

  4. Running the downloaded file

  5. Installing on D:\msys64 (my harddrive), next, uncheck "Run MSYS 64bit now" and click finish

  6. Editing msys2.ini by right clicking in explorer and edit with notepad++ so it will contain

    MSYSTEM=MSYS
    HOME=/home/user
    USER=user
    

    (there must be no extra line)

  7. Adding to .bash_profile

    PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig
    ACLOCAL_PATH=/mingw64/share/aclocal
    
    export PKG_CONFIG_PATH ACLOCAL_PATH
    
  8. Running msys2.exe from explorer (the output from the console window will show that the home directory and profile files will be automatically created).

  9. Updating the package database with

    pacman -Syu --force
    

    Getting the output "there is nothing to do" twice, once for core system upgrade and once for full system upgrade.

  10. Installing the tools by pasting

    pacman -S base-devel \
    mingw-w64-x86_64-toolchain \
    git \
    mingw-w64-x86_64-gtk2 \
    mingw-w64-x86_64-gtk3 \
    mingw-w64-x86_64-json-glib \
    mingw-w64-x86_64-json-c \
    mingw-w64-x86_64-gexiv2 \
    mingw-w64-x86_64-lcms2 \
    mingw-w64-x86_64-glib-networking \
    mingw-w64-x86_64-poppler \
    mingw-w64-x86_64-gettext
    

    pressing enter-enter-Y

  11. Exiting msys by pressing Ctrl-D

  12. Editing mingw64.ini, by right clicking in explorer and edit with notepad++ so it will contain

    MSYSTEM=MINGW64
    HOME=/home/user
    USER=user
    

    (there must be no extra line)

  13. Running Mingw64.exe from Explorer

  14. Installing libmypaint, by typing

    git clone https://github.com/mypaint/libmypaint.git
    cd libmypaint
    git checkout tags/v1.3.0
    ./autogen.sh
    ./configure
    make
    make install
    cd ~
    
  15. Installing mypaint-brushes, by typing

    git clone https://github.com/Jehan/mypaint-brushes
    cd mypaint-brushes
    git checkout v1.3.x
    ./autogen.sh
    ./configure
    make
    make install
    cd ~
    
  16. Installing babl, by typing

    git clone https://git.gnome.org/browse/babl
    cd babl
    ./autogen.sh --disable-docs
    make
    make install
    cd ~
    

    (make is giving me a lot of warnings, but no errors)

  17. Installing gegl, by typing

    git clone https://gitlab.gnome.org/GNOME/gegl.git/
    cd gegl
    ./autogen.sh --enable-gtk-doc-html=no --disable-docs
    make
    make install
    cd ~
    
  18. Building gimp, by typing

    git clone https://gitlab.gnome.org/GNOME/gimp.git/
    cd gimp
    git revert 8d7f13be186401c4d5c63e6e666b9105ac968dfe
    ./autogen.sh --disable-python --disable-gtk-doc
    make
    make install
    
@cbrt64
Copy link

cbrt64 commented May 30, 2018

Hey Anders, I finally got around to reading this after you updated it, as well as my IRC backlog. So, here are a few pointers I think will be helpful.

A bit of pacman primer:

  • pacman -Sy downloads the repo databases and their sigs to /var/lib/pacman/sync.
  • pacman -Su checks your current installed packages against those local databases, and offers to download/install updates. When this has to do a core system upgrade, which is the main msys2 runtime and stuff, it will ask you to close the window. You will then need to open another terminal and do pacman -Su again, until it doesn't find any more updates.
  • pacman -S <package> ... installs/re-installs packages and their dependencies.
  • If any of these updates break files during download you may need --force only in that instance, it basically downloads even if you already have the db or packages in question.
  • I recommend reading man pacman.
  • The package files are downloaded to /var/cache/pacman/pkg, you can save/relocate these if you ever want to do a clean reinstall without re-downloading them all.

Your msys2 installation was definitely messed up somehow, probably by a broken download. In case there is anything else wrong, you could do pacman -Qkq to see if any files are missing. This will take a while.

However, I think your problem is that you have both toolchains: I recommend having only mingw-gcc, and not gcc, as they may conflict (Kevin mentioned this on IRC). pacman -R msys2-devel glib2-dev will take care of this.

You should use the mingw64 shell for building gimp etc., and msys shell for pacman or other msys2 maintenance.

If you read Building GIMP on Windows, you'll see it says to set your build environment; unless you put it in .bash_profile you'll need to do this every time you open a new shell. (I put mine in a pre-build script and run it only before I make etc.) This should be done between your steps 9 and 10.

export PREFIX=\`realpath {wherever/you/want}\`
export PATH="$PREFIX/bin:$PATH"
export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export LD_LIBRARY_PATH="$PREFIX/lib:$LD_LIBRARY_PATH"
export ACLOCAL_FLAGS="-I $PREFIX/share/aclocal -I $MINGW_PREFIX/share/aclocal"
mkdir -p $PREFIX/share/aclocal

Unless you don't intend to install gimp or other things you built, you should set $PREFIX as above and pass --prefix=$PREFIX to ./autogen.sh (or ./configure in the case of *mypaint*). Otherwise make install will install to /mingw64, which should be reserved for mingw's pacman/repo packages to minimize headaches.

Finally, to get around the failing bug 795855 / https://github.com/Alexpux/MINGW-packages/issues/3584 glib2 version check, for now you can cd gimp && git revert 8d7f13be186401c4d5c63e6e666b9105ac968dfe

I just built master from scratch last night on Windows 7 64-bit, in about an hour, so I know it works. :)

@AndersBillLinden
Copy link
Author

What is PREFIX good for?

@AndersBillLinden
Copy link
Author

Also, what is the difference between the msys shell and the mingw64 shell?

@cbrt64
Copy link

cbrt64 commented Jun 3, 2018

@AndersBillLinden,

pacman -S mingw-w64-x86_64-toolchain installs mingw-w64-x86_64-gcc, which is the one you want, not gcc.
As I mentioned above, you have both toolchains, which can/will conflict.
Do pacman -R msys2-devel after you've already installed gcc to get rid of it and its dependencies.

PREFIX is how you tell make install where to put the app you've built. If you don't set it, or forget to pass it to autogen.sh/configure, the files will get installed in /usr or /ming64, which are better left to pacman (example: cd babl && make install, without PREFIX, will put the files in /mingw64, clobbering any files you've installed with pacman -S babl.

The msys shell pulls libraries, includes, etc. from /usr, and is for building pacman packages with makepkg, which is supposed to use msys2-devel/gcc. You want the mingw shell (which pulls from /mingw64) if you're only building stuff to use for yourself.

Msys2 binaries, built with gcc, are linked against msys-2.dll, which is a fork of cygwin1.dll.
Mingw-w64 binaries, built with mingw-w64-x86_64-gcc, are linked against msvcrt.dll that comes with Windows, so they are "native stand-alone" Windows apps.

@AndersBillLinden
Copy link
Author

AndersBillLinden commented Jun 4, 2018

I have now updated this gist, getting an error when using autogen.sh in the gimp project as you can see.

  • I use msys2 for pacman and mingw64 for the building as you have indicated (still I do not know the difference between those shells).
  • I do not use PREFIX at all, assuming the defaults are good.
  • I am using mingw-w64-x86_64-gcc instead of gcc.

@cbrt64
Copy link

cbrt64 commented Jun 5, 2018

@AndersBillLinden, I tried changing glib2.0.pc, I think I got the same error as you did. There are more .pc files involved and they probably all need to match. Instead, just get rid of the configure check, the latest mingw glib2 is now fixed anyway.
pacman -S mingw-w64-x86_64-glib2 # to reset edited glib .pc files
cd gimp && git checkout configure.ac && git revert 8d7f13be186401c4d5c63e6e666b9105ac968dfe # to remove the special version check

@AndersBillLinden
Copy link
Author

AndersBillLinden commented Jun 5, 2018

I have got an advice on #gimp that I should alter configure.ac in the gimp project instead of modifying any pc files.
I have no experience on that syntax, but included the snippet I am supposed to change. It is about changing a call of AM_PATH_GLIB_2_0 to PKG_CHECK_MODULES @cbrt64

@AndersBillLinden
Copy link
Author

Success! Thanks for your help! @cbrt64

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