Skip to content

Commit

Permalink
Getting Windows cross-compilation to work on my Mac
Browse files Browse the repository at this point in the history
I don't know if this would solve gregorio-project#1289 on Linux machines, but at least on my Mac I can now build a windows executable and installer with this.
  • Loading branch information
rpspringuel committed Feb 18, 2025
1 parent 136a63c commit 88640d9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
19 changes: 13 additions & 6 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# --jobs= : the number of jobs to run simultaneously in the make step
# --force= : force autoreconf
# {other) : anything else is passed to configure verbatim

# try to find bash, in case the standard shell is not capable of
# handling the generated configure's += variable assignments
if which bash >/dev/null
Expand All @@ -33,7 +33,7 @@ then
export MAKE
echo "You have a GNU-make installed as gmake; I will use that"
else
echo "I can't find a GNU-make; I'll try to use make and hope that works."
echo "I can't find a GNU-make; I'll try to use make and hope that works."
echo "If it doesn't, please install GNU-make."
fi

Expand Down Expand Up @@ -67,12 +67,19 @@ if [ "$MINGWCROSS" = "TRUE" ]
then
MINGWBUILD=$HOSTTYPE-$OSTYPE
MINGWSTR=mingw32
PREFIX=/usr/
if [ -d /usr/mingw32 ]; then
MINGWSTR=mingw32
PREFIX=/usr/
elif [ -d /usr/i386-mingw32msvc ]; then
MINGWSTR=i386-mingw32msvc
MINGWSTR=i386-mingw32msvc
PREFIX=/usr/
elif [ -d /usr/i586-mingw32msvc ]; then
MINGWSTR=i586-mingw32msvc
MINGWSTR=i586-mingw32msvc
PREFIX=/usr/
elif [ -d /opt/local/i686-w64-mingw32 ]; then
MINGWSTR=i686-w64-mingw32
PREFIX=/opt/local/
fi
OLDPATH=$PATH
PATH=/usr/$MINGWSTR/bin:$PATH
Expand All @@ -82,7 +89,7 @@ then
--with-gnu-ld \
--host=$MINGWSTR \
--build=$MINGWBUILD \
--prefix=/usr/$MINGWSTR"
--prefix=$PREFIX$MINGWSTR"
elif [ "$MACCROSS" = "TRUE" ]
then
# make sure that architecture parameter is valid
Expand All @@ -92,7 +99,7 @@ then
esac
ARCHFLAGS="$ARCHFLAGS"
CFLAGS="-arch $ARCH -g -O2 $CFLAGS"
LDFLAGS="-arch $ARCH $LDFLAGS"
LDFLAGS="-arch $ARCH $LDFLAGS"
fi


Expand Down
24 changes: 18 additions & 6 deletions windows/windows_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,31 @@

This folder is dedicated to the windows installer. This file describes the steps to compile it.

### Building the gregorio executable
## Building the gregorio executable

Building the `gregorio.exe` file cannot currently be made under Windows, but it is possible under Linux:
### Linux Hosts

* install [mingw](http://www.mingw.org/) (`aptitude install mingw32` under Debian)
While building the executable under Windows should be possible, none of the current developers build it that way, so we are unable to provide the exact steps required to do so.

Building under Linux worked when the mingw32 package was available using the following instructions:

* install mingw32 (`aptitude install mingw32` under Debian)
* run `./build.sh --mingw` in the main directory of the repository

This will create `src/gregorio.exe`.
However, the mingw32 package has not been available in the package repositories for several years (for Ubuntu, the 14.04 repositories are the most recent to contain it). The more recent mingw-w64 package is the appropriate replacement, but as of yet we have not confirmed that it works.

### macOS Hosts

Building under macOS is possible using the following steps:

- install [mingw-w64](https://mingw-w64.sourceforge.net/) using MacPorts: `port install mingw-w6` (most likely requires `sudo`)
- run `./build.sh` in the main directory of the repository to build the native Mac binaries first (this is needed because some intermediate build steps require running files that have been built in earlier steps)
- run `./build.sh --mingw` in the same directory to build the windows executable

**Note:** Currently the build script only supports building a 32-bit executable (using mingw32). This package is not available by default on Ubuntu 16.04 or later. Anyone willing to help us update the build script to use the 64-bit cross compilers that are readily available on more recent versions of Ubuntu (or other *nix distributions) is very much welcome.
This will create `src/gregorio-<version number>.exe`

### Building the installer

You need [InnoSetup](http://www.jrsoftware.org/isinfo.php) to be able to compile the installer. It runs fine under [Wine](https://www.winehq.org/). Once you have it installed: run InnoSetup.exe, open the `windows/gregorio.iss` file and compile it, it will produce `windows/Output/setup.exe`. You can also run it from command line: `wine 'C:\\Program Files (x86)\Inno Setup 5\ISCC.exe' gregorio.iss` in the `windows` directory (replace the `ISCC.exe` path with yours if different).
You need [InnoSetup](http://www.jrsoftware.org/isinfo.php) to be able to compile the installer. It runs fine under [Wine](https://www.winehq.org/). Once you have it installed: run InnoSetup.exe, open the `windows/gregorio.iss` file and compile it, it will produce `windows/Output/setup.exe`. You can also run it from command line: `wine 'C:\\Program Files (x86)\Inno Setup 6\ISCC.exe' gregorio.iss` in the `windows` directory (replace the `ISCC.exe` path with yours if different).

**Note:** If you're building the compiler on Ubuntu 14.04 (because of the above issue with mingw32) then you will need Inno Setup 5.x. This is because the version of wine available on Ubuntu 14.04 emulates a version of Windows which is not compatible with Inno Setup 6.x.

0 comments on commit 88640d9

Please sign in to comment.