Compiling MegaZeux: Difference between revisions

From MZXWiki
Jump to navigation Jump to search
No edit summary
m (Added msys-related formatting/clarification, and Troubleshooting.)
Line 19: Line 19:


===Windows with MSYS2===
===Windows with MSYS2===
Download and install msys2 (these instructions are for msys2-x86_64-20161025.exe specifically)
Download and install '''msys2''' (these instructions are for '''msys2-x86_64-20161025.exe''' specifically)
   
   
Run mingw64.exe in the msys2 directory. You will be in {MSYS DIRECTORY}\home\{USERNAME}\
Run '''mingw64.exe''' in the ''msys2'' directory. You will be in the "{MSYS DIRECTORY}\home\{your username}\" directory.  (This will display in the mingw64 shell as either "~" or "/home/{your username}")
   
   
Run the following commands.
Run the following commands.
Line 37: Line 37:
  ./config.sh --platform win32 --enable-libsdl2
  ./config.sh --platform win32 --enable-libsdl2
  make
  make
MegaZeux should be built and ready to run!  Ensure your PATH environment variable contains the dependencies you installed (located by default in ''C:\msys64\mingw64\bin'').


===Windows with Git Bash and MinGW===
===Windows with Git Bash and MinGW===
Line 154: Line 155:
  make archive
  make archive
A .dmg will appear in build/arch/darwin/.  Please refer to the documentation in arch/darwin/ for more details.
A .dmg will appear in build/arch/darwin/.  Please refer to the documentation in arch/darwin/ for more details.
==Troubleshooting==
===Windows===
''"The program can't start because ___.dll is missing."''
Ensure that your PATH contains the directory where MZX's dependency's binary files reside.  If using msys2, this should be <nowiki>C:\msys64\mingw64\bin</nowiki>.
''"The procedure entry point inflateReset2 could not be located in the dynamic link library zlib1.dll."''
This can happen because the PATH variable contains an older copy of ''zlib1.dll''.  You can use ''where zlib1.dll'' in a command prompt to check the order in which Windows looks for the binary.  Edit your account or system PATH environment variable and make sure that the appropriate copy of ''zlib1.dll'' is being loaded first.

Revision as of 16:36, 8 June 2017

Compiling any MegaZeux 2.8x source requires a POSIX compatible shell (bash, dash) to be installed. Download the source .tar.bz2 or .tar.xz and extract it to a new folder.

Building

./config.sh

This will give you help about how to configure MegaZeux.

./config.sh --platform unix

To configure the sources. On OS X, the platform is "darwin", and on win32 the platform is "win32".

make

This will build MegaZeux from sources. If it fails, you probably don't have one of SDL, libvorbis, libogg, libpng, zlib or the corresponding dev packages installed.

make install

This will install MegaZeux to the system. Do not use for the "unix-devel" platform, which is intended to run straight out of the source directory.

Please see debian/README for more information.


Windows with MSYS2

Download and install msys2 (these instructions are for msys2-x86_64-20161025.exe specifically)

Run mingw64.exe in the msys2 directory. You will be in the "{MSYS DIRECTORY}\home\{your username}\" directory. (This will display in the mingw64 shell as either "~" or "/home/{your username}")

Run the following commands.

yes Y | pacman -S git
yes Y | pacman -S make
yes Y | pacman -S mingw-w64-x86_64-zlib
yes Y | pacman -S mingw-w64-x86_64-gcc
yes Y | pacman -S mingw-w64-x86_64-libpng
yes Y | pacman -S mingw-w64-x86_64-libogg
yes Y | pacman -S mingw-w64-x86_64-libvorbis
yes Y | pacman -S mingw-w64-x86_64-SDL2
git clone https://github.com/AliceLR/megazeux.git
cd megazeux
./config.sh --platform win32 --enable-libsdl2
make

MegaZeux should be built and ready to run! Ensure your PATH environment variable contains the dependencies you installed (located by default in C:\msys64\mingw64\bin).

Windows with Git Bash and MinGW

These instructions are intended to help you build and install all of MZX's dependencies from scratch to bin/mingw32/ in your home folder. The format of MZXPREFIX (c: instead of /c, forward slashes) is mandatory. The required dependencies for MZX are zlib, libpng, libogg and libvorbis, and one of SDL 1.2 or SDL 2.0 (as of GIT/version 2.85, requires the --enable-libsdl2 config.sh flag).

This requires Git installed to C:\Git, and MinGW installed to C:\MinGW. MinGW's bin folder must be on your path. Do not install Git or MinGW to Program Files or any other path with a space in it.

Do not install Git to Program Files.

Do not install Git to Program Files.

Do not install Git to Program Files.

Do this first:

echo "export MZXPREFIX=c:/users/\$(whoami)/bin/mingw32" >> ~/.bashrc
echo "export PATH=\"\$PATH:$MZXPREFIX/bin\"" >> ~/.bashrc
echo "export SDL_STDIO_REDIRECT=no" >> ~/.bashrc
. ~/.bashrc
mkdir ~/bin
mkdir $MZXPREFIX
mkdir $MZXPREFIX/bin

Compiling zlib: one of these two methods may work.

make -f win32/Makefile.gcc
make -f win32/Makefile.gcc install INCLUDE_PATH=$MZXPREFIX/include/ LIBRARY_PATH=$MZXPREFIX/lib/ BINARY_PATH=$MZXPREFIX/bin/
./configure --static --64
cp Makefile Makefile.old
cp win32/Makefile.gcc Makefile
make
make install INCLUDE_PATH=$MZXPREFIX/include/ LIBRARY_PATH=$MZXPREFIX/lib/ BINARY_PATH=$MZXPREFIX/bin/

Compiling libpng16: libpng folder should be in the same folder as the zlib folder, they should be called "libpng" and "zlib", and zlib should already be built. For versions other than libpng16, replace the '16'.

cp scripts/pnglibconf.h.prebuilt pnglibconf.h
cp scripts/makefile.gcc makefile
make static
cp scripts/makefile.msys makefile
make libpng-config
mkdir $MZXPREFIX/include/libpng16/
cp libpng-config $MZXPREFIX/bin/
cp libpng.a $MZXPREFIX/lib/libpng16.a
cp png.h pngconf.h pnglibconf.h $MZXPREFIX/include/libpng16/

Compiling libogg and libvorbis: these instructions should work for both.

./configure --prefix=$MZXPREFIX --disable-shared
make
make install

Compiling SDL 1.2 and SDL 2.0: these instructions should work for both.

./configure --build=mingw32 --prefix=$MZXPREFIX
make
make install INSTALL=/c/Git/usr/bin/install.exe

Compiling MZX:

./config.sh --platform win64 --prefix $MZXPREFIX [other options, i.e. --enable-libsdl2]
make

If MZX fails to compile libmodplug due to a previous declaration of Sleep(), edit contrib/libmodplug/src/libmodplug/stdafx.h and comment out line 42:

//#define sleep(_ms)      Sleep(_ms)

Ubuntu/Debian

sudo apt-get install gcc g++

We need compilers!

supo apt-get install libsdl1.2-dev libogg-dev libvorbis-dev libpng-dev

Download our dependencies.

The above instructions should work now.


Mac OS X

You will need to install XCode and optionally MacPorts before continuing.

NOTE: Using MacPorts is not acceptable for official releases! Use it for personal builds only.

Determine the name of your compiler before continuing; typing 'i686-' or 'powerpc-' and pressing tab twice should be sufficient. Example output:

i686-apple-darwin10-g++-4.2.1 i686-apple-darwin10-gcc-4.2.1

Compile/install dependencies. If you're using MacPorts:

sudo port install libsdl libogg libvorbis libpng

Navigate to the extracted source directory. If you're building MZX 2.84 and under, please download this updated Makefile.in and put it in arch/darwin/, otherwise MegaZeux will fail to compile.

Run ./config.sh. Consider the following flags:

--platform darwin   ---------- Mandatory.
--disable-x11       ---------- Also mandatory.
--disable-utils     ---------- This disables compilation of utilities such as downver and checkres.  This is optional.
--enable-release    ---------- Removes debug symbols.  This will make the package smaller if you intend on installing MZX in app form.
--prefix /opt/local ---------- Mandatory if you're using MacPorts; omit otherwise.

Make options:

ARCH={ your architecture: i686, amd64, ppc, or ppc64 }
CROSS_COMPILE_{ X86 or PPC }_CC={ name of your gcc compiler}
CROSS_COMPILE_{ X86 or PPC }_CXX={ name of your g++ compiler}

Run make:

make ARCH=i686 CROSS_COMPILE_X86_CC=i686-apple-darwin10-gcc-4.2.1 CROSS_COMPILE_X86_CXX=i686-apple-darwin10-g++-4.2.1

Hopefully nothing will go wrong! :)

Packaging

Mac OS X

Make sure there is not a "MegaZeux" volume mounted before continuing.

rm -r build/
make lipo
make archive

A .dmg will appear in build/arch/darwin/. Please refer to the documentation in arch/darwin/ for more details.

Troubleshooting

Windows

"The program can't start because ___.dll is missing."

Ensure that your PATH contains the directory where MZX's dependency's binary files reside. If using msys2, this should be C:\msys64\mingw64\bin.

"The procedure entry point inflateReset2 could not be located in the dynamic link library zlib1.dll."

This can happen because the PATH variable contains an older copy of zlib1.dll. You can use where zlib1.dll in a command prompt to check the order in which Windows looks for the binary. Edit your account or system PATH environment variable and make sure that the appropriate copy of zlib1.dll is being loaded first.