[Windows] Building 64-bit minetest with MSYS2/mingw64

Post Reply
User avatar
Fixer
Member
Posts: 896
Joined: Sun Jul 31, 2011 11:23
IRC: Fixer
In-game: Fixer
Location: Ukraine

[Windows] Building 64-bit minetest with MSYS2/mingw64

by Fixer » Post

Building 64bit Minetest under Windows by using MSYS2/Mingw64 environment (C++11 compatible)

MSYS2 is a software distro and building platform for Windows. At its core is an independent rewrite of MSYS, based on modern Cygwin (POSIX compatibility layer) and MinGW-w64 with the aim of better interoperability with native Windows software. It provides a bash shell, Autotools, revision control systems and the like for building native Windows applications using MinGW-w64 toolchains. Windows XP and FAT partitions are not supported!

Installation:
* Go to http://www.msys2.org/ and download msys2-x86-64 installer
* Follow install instructions on website (important)

After MSYS2 is fully installed and updated, follow steps below.
The commands shown below should be run from within the MSYS2 Shell (Start -> MSYS2 64bit -> MSYS2 MinGW 64-bit)

* To install git and the base development packages, run:

Code: Select all

pacman -S base-devel git unzip
* To install the mingw-w64 GCC toolchain and cmake for your system, run:

Code: Select all

pacman -S mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake
* Close it and start "MSYS2 MinGW 64-bit" again
* You will appear in your home directory, execute this command to create directories for building:

Code: Select all

mkdir minetest minetest/build minetest/buildbot minetest/build/copy2bin
* Execute this to change directory and download compile scripts:

Code: Select all

cd ~/minetest/buildbot
wget https://raw.githubusercontent.com/minetest/minetest/master/util/buildbot/buildwin64.sh
wget https://raw.githubusercontent.com/minetest/minetest/master/util/buildbot/toolchain_mingw64.cmake
* Modify toolchain_mingw64.cmake with your favourite editor in msys2 or with usual tools, like notepad++:
** Replace

Code: Select all

SET(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
with

Code: Select all

SET(CMAKE_RC_COMPILER windres)
** Replace

Code: Select all

SET(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
with

Code: Select all

SET(CMAKE_FIND_ROOT_PATH /mingw64/x86_64-w64-mingw32)
* Now modify buildwin64.sh:
** go to "cmake .. \" section and insert those lines right below it:

Code: Select all

-G"MinGW Makefiles" \
-DCMAKE_AR=/mingw64/x86_64-w64-mingw32/bin/ar \
** near end of the file replace

Code: Select all

make package -j2
with

Code: Select all

mingw32-make package -j$(nproc)
* Go to /usr/bin and rename sh.exe to sh.exe~ (to avoid CMAKE errors, please show me better way):

Code: Select all

mv /usr/bin/sh.exe /usr/bin/sh.exe~
* Copy those libraries from /mingw64/bin to ~/minetest/build/copy2bin for easier access, those will be needed:

Code: Select all

cp /mingw64/bin/libgcc_s_seh-1.dll ~/minetest/build/copy2bin/
cp /mingw64/bin/libstdc++-6.dll ~/minetest/build/copy2bin/
cp /mingw64/bin/libwinpthread-1.dll ~/minetest/build/copy2bin/
* Now go back to your buildbot directory:

Code: Select all

cd ~/minetest/buildbot
and execute final building script:

Code: Select all

./buildwin64.sh ../build
* This will start minetest compilation.
* Compiled minetest will appear in ~/minetest/build/minetest/_build directory with name like minetest-0.4.16-bla-bla-win64.zip
* Final touch, copy files from copy2bin directory into this compiled minetest zip archive into /bin where minetest.exe is located.

* Done! You are ready!

* If you want to compile newer version of minetest, run "./buildwin64.sh ../build" again:

Code: Select all

cd ~/minetest/buildbot
./buildwin64.sh ../build
It will automatically update all files and repos if need, all you need is to wait for compilation completion and add those 3 dlls into /bin directory of zip file with compiled minetest. You can modify buildwin64.sh script to your needs, for example, to avoid full recompilation - don't run cmake, unless there were CMakeLists.txt changes, just run "mingw32-make package -j$(nproc)". Doing sh.exe rename before/after cmake is also advised. Without sh.exe some other features will not work properly, like git bisect and other.

Here is my final buildbot script that should work, copy it to .sh file and run it within MSYS2 MinGW 64-bit shell:

Code: Select all

#!/bin/bash
# Using cmake for regular compile with recompile everything (slow)
# Use buildwin64_compileonly.sh to compile fast, and use this if problems

set -e

{
echo -n "Start of compilation: "; date -R

dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ $# -ne 1 ]; then
	echo "Usage: $0 <build directory>"
	exit 1
fi
builddir=$1
mkdir -p $builddir
builddir="$( cd "$builddir" && pwd )"
packagedir=$builddir/packages
libdir=$builddir/libs

toolchain_file=$dir/toolchain_mingw64.cmake
irrlicht_version=1.8.4
ogg_version=1.3.2
vorbis_version=1.3.5
curl_version=7.54.0
gettext_version=0.19.8.1
freetype_version=2.8
sqlite3_version=3.19.2
luajit_version=2.1.0-beta3
leveldb_version=1.19
zlib_version=1.2.11

mkdir -p $packagedir
mkdir -p $libdir

cd $builddir

# Get stuff
[ -e $packagedir/irrlicht-$irrlicht_version.zip ] || wget http://minetest.kitsunemimi.pw/irrlicht-$irrlicht_version-win64.zip \
	-c -O $packagedir/irrlicht-$irrlicht_version.zip
[ -e $packagedir/zlib-$zlib_version.zip ] || wget http://minetest.kitsunemimi.pw/zlib-$zlib_version-win64.zip \
	-c -O $packagedir/zlib-$zlib_version.zip
[ -e $packagedir/libogg-$ogg_version.zip ] || wget http://minetest.kitsunemimi.pw/libogg-$ogg_version-win64.zip \
	-c -O $packagedir/libogg-$ogg_version.zip
[ -e $packagedir/libvorbis-$vorbis_version.zip ] || wget http://minetest.kitsunemimi.pw/libvorbis-$vorbis_version-win64.zip \
	-c -O $packagedir/libvorbis-$vorbis_version.zip
[ -e $packagedir/curl-$curl_version.zip ] || wget http://minetest.kitsunemimi.pw/curl-$curl_version-win64.zip \
	-c -O $packagedir/curl-$curl_version.zip
[ -e $packagedir/gettext-$gettext_version.zip ] || wget http://minetest.kitsunemimi.pw/gettext-$gettext_version-win64.zip \
	-c -O $packagedir/gettext-$gettext_version.zip
[ -e $packagedir/freetype2-$freetype_version.zip ] || wget http://minetest.kitsunemimi.pw/freetype2-$freetype_version-win64.zip \
	-c -O $packagedir/freetype2-$freetype_version.zip
[ -e $packagedir/sqlite3-$sqlite3_version.zip ] || wget http://minetest.kitsunemimi.pw/sqlite3-$sqlite3_version-win64.zip \
	-c -O $packagedir/sqlite3-$sqlite3_version.zip
[ -e $packagedir/luajit-$luajit_version.zip ] || wget http://minetest.kitsunemimi.pw/luajit-$luajit_version-win64.zip \
	-c -O $packagedir/luajit-$luajit_version.zip
[ -e $packagedir/libleveldb-$leveldb_version.zip ] || wget http://minetest.kitsunemimi.pw/libleveldb-$leveldb_version-win64.zip \
	-c -O $packagedir/libleveldb-$leveldb_version.zip
[ -e $packagedir/openal_stripped.zip ] || wget http://minetest.kitsunemimi.pw/openal_stripped64.zip \
	-c -O $packagedir/openal_stripped.zip


# Extract stuff
cd $libdir
[ -d irrlicht ] || unzip -o $packagedir/irrlicht-$irrlicht_version.zip -d irrlicht
[ -d zlib ] || unzip -o $packagedir/zlib-$zlib_version.zip -d zlib
[ -d libogg ] || unzip -o $packagedir/libogg-$ogg_version.zip -d libogg
[ -d libvorbis ] || unzip -o $packagedir/libvorbis-$vorbis_version.zip -d libvorbis
[ -d libcurl ] || unzip -o $packagedir/curl-$curl_version.zip -d libcurl
[ -d gettext ] || unzip -o $packagedir/gettext-$gettext_version.zip -d gettext
[ -d freetype ] || unzip -o $packagedir/freetype2-$freetype_version.zip -d freetype
[ -d sqlite3 ] || unzip -o $packagedir/sqlite3-$sqlite3_version.zip -d sqlite3
[ -d openal_stripped ] || unzip -o $packagedir/openal_stripped.zip
[ -d luajit ] || unzip -o $packagedir/luajit-$luajit_version.zip -d luajit
[ -d leveldb ] || unzip -o $packagedir/libleveldb-$leveldb_version.zip -d leveldb

# Get minetest
cd $builddir
if [ ! "x$EXISTING_MINETEST_DIR" = "x" ]; then
	ln -s $EXISTING_MINETEST_DIR minetest
else
	[ -d minetest ] && (cd minetest && git pull) || (git clone https://github.com/minetest/minetest)
fi
cd minetest
git_hash=$(git rev-parse --short HEAD)

# Get minetest_game
cd games
if [ "x$NO_MINETEST_GAME" = "x" ]; then
	[ -d minetest_game ] && (cd minetest_game && git pull) || (git clone https://github.com/minetest/minetest_game)
fi
cd ../..

# Build the thing
cd minetest
[ -d _build ] && rm -Rf _build/
mkdir _build
cd _build
mv /usr/bin/sh.exe /usr/bin/sh.exe~
cmake .. \
	-G"MinGW Makefiles" \
	-DCMAKE_AR=/mingw64/x86_64-w64-mingw32/bin/ar \
	-DCMAKE_TOOLCHAIN_FILE=$toolchain_file \
	-DCMAKE_INSTALL_PREFIX=/tmp \
	-DVERSION_EXTRA=$git_hash \
	-DBUILD_CLIENT=1 -DBUILD_SERVER=0 \
	\
	-DENABLE_SOUND=1 \
	-DENABLE_CURL=1 \
	-DENABLE_GETTEXT=1 \
	-DENABLE_FREETYPE=1 \
	-DENABLE_LEVELDB=1 \
	\
	-DIRRLICHT_INCLUDE_DIR=$libdir/irrlicht/include \
	-DIRRLICHT_LIBRARY=$libdir/irrlicht/lib/Win64-gcc/libIrrlicht.dll.a \
	-DIRRLICHT_DLL=$libdir/irrlicht/bin/Win64-gcc/Irrlicht.dll \
	\
	-DZLIB_INCLUDE_DIR=$libdir/zlib/include \
	-DZLIB_LIBRARIES=$libdir/zlib/lib/libz.dll.a \
	-DZLIB_DLL=$libdir/zlib/bin/zlib1.dll \
	\
	-DLUA_INCLUDE_DIR=$libdir/luajit/include \
	-DLUA_LIBRARY=$libdir/luajit/libluajit.a \
	\
	-DOGG_INCLUDE_DIR=$libdir/libogg/include \
	-DOGG_LIBRARY=$libdir/libogg/lib/libogg.dll.a \
	-DOGG_DLL=$libdir/libogg/bin/libogg-0.dll \
	\
	-DVORBIS_INCLUDE_DIR=$libdir/libvorbis/include \
	-DVORBIS_LIBRARY=$libdir/libvorbis/lib/libvorbis.dll.a \
	-DVORBIS_DLL=$libdir/libvorbis/bin/libvorbis-0.dll \
	-DVORBISFILE_LIBRARY=$libdir/libvorbis/lib/libvorbisfile.dll.a \
	-DVORBISFILE_DLL=$libdir/libvorbis/bin/libvorbisfile-3.dll \
	\
	-DOPENAL_INCLUDE_DIR=$libdir/openal_stripped/include/AL \
	-DOPENAL_LIBRARY=$libdir/openal_stripped/lib/libOpenAL32.dll.a \
	-DOPENAL_DLL=$libdir/openal_stripped/bin/OpenAL32.dll \
	\
	-DCURL_DLL=$libdir/libcurl/bin/libcurl-4.dll \
	-DCURL_INCLUDE_DIR=$libdir/libcurl/include \
	-DCURL_LIBRARY=$libdir/libcurl/lib/libcurl.dll.a \
	\
	-DGETTEXT_MSGFMT=`which msgfmt` \
	-DGETTEXT_DLL=$libdir/gettext/bin/libintl-8.dll \
	-DGETTEXT_ICONV_DLL=$libdir/gettext/bin/libiconv-2.dll \
	-DGETTEXT_INCLUDE_DIR=$libdir/gettext/include \
	-DGETTEXT_LIBRARY=$libdir/gettext/lib/libintl.dll.a \
	\
	-DFREETYPE_INCLUDE_DIR_freetype2=$libdir/freetype/include/freetype2 \
	-DFREETYPE_INCLUDE_DIR_ft2build=$libdir/freetype/include/freetype2 \
	-DFREETYPE_LIBRARY=$libdir/freetype/lib/libfreetype.dll.a \
	-DFREETYPE_DLL=$libdir/freetype/bin/libfreetype-6.dll \
	\
	-DSQLITE3_INCLUDE_DIR=$libdir/sqlite3/include \
	-DSQLITE3_LIBRARY=$libdir/sqlite3/lib/libsqlite3.dll.a \
	-DSQLITE3_DLL=$libdir/sqlite3/bin/libsqlite3-0.dll \
	\
	-DLEVELDB_INCLUDE_DIR=$libdir/leveldb/include \
	-DLEVELDB_LIBRARY=$libdir/leveldb/lib/libleveldb.dll.a \
	-DLEVELDB_DLL=$libdir/leveldb/bin/libleveldb.dll

mv /usr/bin/sh.exe~ /usr/bin/sh.exe
mingw32-make package -j$(nproc)

cd _CPack_Packages/win64/ZIP/
cp /mingw64/bin/libgcc_s_seh-1.dll minetest-*/bin
cp /mingw64/bin/libstdc++-6.dll minetest-*/bin
cp /mingw64/bin/libwinpthread-1.dll minetest-*/bin
zip -ur minetest-*.zip minetest-*
cp minetest-*.zip ../../../

echo -n "End of compilation: "; date -R

} |& tee build.log

# EOF 

User avatar
ChimneySwift
Member
Posts: 320
Joined: Fri Sep 22, 2017 06:46
GitHub: ChimneySwift
IRC: ChimneySwift
In-game: ChimneySwift
Location: 127.0.0.1

Re: [Windows] Building 64-bit minetest with MSYS2/mingw64

by ChimneySwift » Post

Thank you so much for this!

I was tearing my hair out trying to compile manually but this is much nicer! I made some modifications but the basis of my success has been this post.
A spoon is basically a tiny bowl with a stick on it

bomberman
Member
Posts: 10
Joined: Fri May 19, 2017 05:24

Re: [Windows] Building 64-bit minetest with MSYS2/mingw64

by bomberman » Post

it downloads version 0.5, how download 0.4.16 with this script?

User avatar
Fixer
Member
Posts: 896
Joined: Sun Jul 31, 2011 11:23
IRC: Fixer
In-game: Fixer
Location: Ukraine

Re: [Windows] Building 64-bit minetest with MSYS2/mingw64

by Fixer » Post

bomberman wrote:it downloads version 0.5, how download 0.4.16 with this script?
I don't remember exactly, but after "git clone https://github.com/minetest/minetest" step you should do "git checkout 80dc961d24e1964e25d57039ddb2ba639f9f4d22", it will switch to 0.4.16, don't forget to DL minetest_game 0.4.16 for it.

Enrikoo
Member
Posts: 452
Joined: Thu Nov 16, 2017 18:18
GitHub: Enrikoo
IRC: Enrico - Enricoo - Enrlco
In-game: Enrico - Enriko
Location: Germany
Contact:

Re: [Windows] Building 64-bit minetest with MSYS2/mingw64

by Enrikoo » Post

The information is outdated, because I get cmake errors, can you renew these informations please so, that I don't get cmake errors anymore?

Thanks.

User avatar
sirrobzeroone
Member
Posts: 191
Joined: Mon Jul 16, 2018 07:56

Re: [Windows] Building 64-bit minetest with MSYS2/mingw64

by sirrobzeroone » Post

Just wanted to say I got a successful win64 build following the above.

couple of minor updates:
this line in the 4th step:

Code: Select all

wget https://raw.githubusercontent.com/minetest/minetest/master/util/buildbot/toolchain_mingw64.cmake
is now this - hopefully, i fished it manually from:
https://github.com/minetest/minetest/bl ... gw32.cmake

Code: Select all

wget https://raw.githubusercontent.com/minetest/minetest/master/util/buildbot/toolchain_x86_64-w64-mingw32.cmake
The line in buildwin64.sh that was

Code: Select all

make package -j2 
is now 
make -j$(nproc) 
replacing it with the same thing above(mingw32-make package -j$(nproc) ) works okay

The only other snag I hit was getting all the packages, they failed to retrieve a few times then worked, then my irrlicht download was corrupt so I manually downloaded that one, renamed it and placed it in the packages folder. No idea what was going on but might have been my local isp...

Next step try a build including lua socket as per this thread:
viewtopic.php?f=11&t=3905&p=313655#p313655

User avatar
sirrobzeroone
Member
Posts: 191
Joined: Mon Jul 16, 2018 07:56

Re: [Windows] Building 64-bit minetest with MSYS2/mingw64

by sirrobzeroone » Post

Hmm...not sure what I did but in trying to incorporate lua sockets for irc I have in someway broken or made this no longer work and unsure how...

I'm now getting the awesome "zst14 dynamic link library" error

I've tried:
  • a full removal of all components and reinstall - same bug,
  • a full install under a fresh win profile without touching any lua sockets - same bug
  • a whole bunch of combos in between with re-downloading files and settings - same bug
Beyond my skillset to diagnose or fix so I'm trying other paths to compile, Just wanted to add this in case anyone has seen it before and solved it, or some other poor person sees this in the future.

User avatar
sirrobzeroone
Member
Posts: 191
Joined: Mon Jul 16, 2018 07:56

Re: [Windows] Building 64-bit minetest with MSYS2/mingw64

by sirrobzeroone » Post

Something a bit odd going on, tried the above build on fresh physical machine nothing installed but updated win10 OS and same error. I'm fairly sure this has nil to do with minetest as I tried a build against 5.4 dev and 5.3 stable same message.

I dug around a bit and found some info which may point to libstdc++-6.dll being the issue (or one of the others) even though the error mentions libleveldb as beign the issue pretty sure this is a wrong path as I foudn a number of people with different library names int he attached error but eventually linked back to Stdc++ . I noticed the stdc++ file was updated recently on the pkg manager. I tried rolling back to the previous version and then re-compiling but same error (edit: no i didn't rollback...). More than possible I compromised something else in regards to dependencies so Im not that confident in my test. I may have to try manually building the toolchain dependency list for the older version of the library.....that will be very tedious

Not sure if someone else can give the above process a try on a win10 machine and see if they get the same error, just to rule out me being the issue.

I did stumble on another interesting facts - Don't install cmake via the install package and then try to install it under MSYS2 for some reason this causes some confusion at the OS level or at least it did for me and MSYS wont be able to find the cmake path.

This process by Oil_boi seems to work everytime even with me trying to break it:
https://www.youtube.com/watch?v=B4QnlJo ... ex=21&t=0s

I just want to find out now why this process worked for me then flaked out and now wont work at all on any machine I've tried....
Attachments
ZST14.PNG
(17.51 KiB) Not downloaded yet

User avatar
sirrobzeroone
Member
Posts: 191
Joined: Mon Jul 16, 2018 07:56

Re: [Windows] Building 64-bit minetest with MSYS2/mingw64

by sirrobzeroone » Post

Had a look with the tool called dependency walker (image attached). top half of the image is my outcome with my compiled exe that errors, bottom half is the standard working exe from the same place.

My issues seems flagged inside LIBSTDC++-6.DLL when it starts interacting with LIBLEVELDB.DLL....which is not very helpful as the error told me that

My ability to interpret beyond that is nil at the moment. Hoping someone who knows more might be able to provide a direction I should be looking in.

I'll keep hunting though might get lucky.

edit tried a 3rd win10 machine same error....I have no clue how I got a working compile first time through, unless it is some sort of package update which is slightly scrambling things...
Attachments
dependancy comparison.png
(345.39 KiB) Not downloaded yet

User avatar
sirrobzeroone
Member
Posts: 191
Joined: Mon Jul 16, 2018 07:56

Re: [Windows] Building 64-bit minetest with MSYS2/mingw64

by sirrobzeroone » Post

I dropped levelDB out of the buildbot script and compiled a version without leveldb support and it compiled and ran fine (so long as you don't need leveldb).

I guess that means there is a slight incompatibility between MSYS2 stdc++-6 used and the leveldb 1.22 version. Before doing the above I did have a look at compiling a new leveldb dll from source but although it compiled okay on linux I cant find some straightforward info about how to cross compile for windows...lots of old builds but nothing new.

the lines I removed from the buildbot script are below very last entry plus remove those \ joiners

Code: Select all

\   <<< at the end of the previous line group (-DSQLITE3_DLL=$libdir/sqlite3/bin/libsqlite3-0.dll)
	\
	-DLEVELDB_INCLUDE_DIR=$libdir/leveldb/include \
	-DLEVELDB_LIBRARY=$libdir/leveldb/lib/libleveldb.dll.a \
	-DLEVELDB_DLL=$libdir/leveldb/bin/libleveldb.dll
ill keep hunting i would really like a new libleveldb package based on the current dev/git source rather than 1.22 so I can do one final test and confirm it's definitely libleveldb 1.22 is a bit out of date and not that there is some bug in the MSYS2 stdc++ library/package (sorry I may have terms wrong there this is all new to me) .

I'll keep trying but I'll post a working buildbot shellscript sans leveldb support once I incorporate some of the cool extra bits and confirm it works (renaming sh auto coping the needed dlls etc)

User avatar
sirrobzeroone
Member
Posts: 191
Joined: Mon Jul 16, 2018 07:56

Re: [Windows] Building 64-bit minetest with MSYS2/mingw64

by sirrobzeroone » Post

I've quoted fixers post below and made some additions, You can skip to the end and copy my working buildbot script or follow my amended instructions from fixers post to adjust the buildwin64.sh script that is bundled with minetest.

if you do copy the text replace all text in your downloaded buildwin64.sh, I don't recommend creating a new txt doc and renaming it to .sh as this may cause the error below. If you stick with the default install paths and copy locations the script will be located at approximately:
C:\msys64\home\<yourusername>\minetest\buildbot

If you get some random cmake error like "cmake can't find cmakelist.txt" it probably means your buildwin64.sh script has been corrupted in someway - wget a fresh copy a manually make the additions to it and then run it and see if it works. I got some strange errors when messing with sh script formatting, but haven't yet nailed down what does it, I think has to do with carriage returns/line returns but I'm not 100% sure.

I've incorporated all fixers enhancements into my version of the shell script which is based on the current buildscript as of 4 Aug 2020 (I've test run the script over 12 times and it seems solid). I also added zip to the packages to install as you need that to auto add the missing dll's to the zip. I've added some switches so you can elect to include or not include minetest_game or voxelgarden both currently configured as yes. They are right at the top of my file below just change the 1 to a 0.

Note: The below totally removes support for leveldb so if your using that backend not sqlite the below will be no good. I'm still hunting around for a sol'n

The below script auto-builds against the current main repository (or dev build) if you want a release build change

Code: Select all

CORE_BRANCH=master 
to the release number eg 5.3.0 below:

Code: Select all

CORE_BRANCH=5.3.0
if you compile a bunch of different versions in a row you may get an error just manually delete the minetest folder at approximately - C:\msys64\home\<yourusername>\minetest\build. I probably should have adjusted the script to append branch to the folder name....oh well next time.

You will see some warnings as it builds as far as I can tell these are all non critical and don't appear to affect the package compiled - Goodluck :)
Fixer wrote:
Sun Jun 04, 2017 16:28
Building 64bit Minetest under Windows by using MSYS2/Mingw64 environment (C++11 compatible)

Installation:
* Go to http://www.msys2.org/ and download msys2-x86-64 installer
* Follow install instructions on website (important)

After MSYS2 is fully installed and updated, follow steps below.
The commands shown below should be run from within the MSYS2 Shell (Start -> MSYS2 64bit -> MSYS2 MinGW 64-bit)

* To install git and the base development packages, run:

Code: Select all

pacman -S base-devel git unzip
* To install the mingw-w64 GCC toolchain and cmake for your system, run:

Code: Select all

pacman -S mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake zip
* Close it and start "MSYS2 MinGW 64-bit" again
* You will appear in your home directory, execute this command to create directories for building:

Code: Select all

mkdir minetest minetest/build minetest/buildbot minetest/build/copy2bin
* Execute this to change directory and download compile scripts:

Code: Select all

cd ~/minetest/buildbot
wget https://raw.githubusercontent.com/minetest/minetest/master/util/buildbot/buildwin64.sh
wget https://raw.githubusercontent.com/minetest/minetest/master/util/buildbot/toolchain_x86_64-w64-mingw32.cmake
* Modify toolchain_mingw64.cmake with your favourite editor in msys2 or with usual tools, like notepad++:
** Replace

Code: Select all

SET(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
with

Code: Select all

SET(CMAKE_RC_COMPILER windres)
** Replace

Code: Select all

SET(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
with

Code: Select all

SET(CMAKE_FIND_ROOT_PATH /mingw64/x86_64-w64-mingw32)
* Now modify buildwin64.sh:
** go to "cmake .. \" section and insert those lines right below it:

Code: Select all

-G"MinGW Makefiles" \
-DCMAKE_AR=/mingw64/x86_64-w64-mingw32/bin/ar \
remove leveldb support
change line approximatly 109 from

Code: Select all

-DENABLE_LEVELDB=1 \
to

Code: Select all

-DENABLE_LEVELDB=0 \
then delete this bit near line 153 to 157

Code: Select all

\ <<< this is last slash at the end of -DSQLITE3_DLL=$libdir/sqlite3/bin/libsqlite3-0.dll
	\
	-DLEVELDB_INCLUDE_DIR=$libdir/leveldb/include \
	-DLEVELDB_LIBRARY=$libdir/leveldb/lib/libleveldb.dll.a \
	-DLEVELDB_DLL=$libdir/leveldb/bin/libleveldb.dll
** near end of the file replace

Code: Select all

make -j$(nproc)
with

Code: Select all

mingw32-make package -j$(nproc)


* Copy those libraries from /mingw64/bin to ~/minetest/build/copy2bin for easier access, those will be needed:

Code: Select all

cp /mingw64/bin/libgcc_s_seh-1.dll ~/minetest/build/copy2bin/
cp /mingw64/bin/libstdc++-6.dll ~/minetest/build/copy2bin/
cp /mingw64/bin/libwinpthread-1.dll ~/minetest/build/copy2bin/
* Now go back to your buildbot directory:

Code: Select all

cd ~/minetest/buildbot
and execute final building script:

Code: Select all

./buildwin64.sh ../build
* This will start minetest compilation.
* Compiled minetest will appear in ~/minetest/build/minetest/_build directory with name like minetest-0.4.16-bla-bla-win64.zip
* Final touch, copy files from copy2bin directory into this compiled minetest zip archive into /bin where minetest.exe is located.

* Done! You are ready!

* If you want to compile newer version of minetest, run "./buildwin64.sh ../build" again:

Code: Select all

cd ~/minetest/buildbot
./buildwin64.sh ../build
It will automatically update all files and repos if need, all you need is to wait for compilation completion and add those 3 dlls into /bin directory of zip file with compiled minetest. You can modify buildwin64.sh script to your needs, for example, to avoid full recompilation - don't run cmake, unless there were CMakeLists.txt changes, just run "mingw32-make package -j$(nproc)". Doing sh.exe rename before/after cmake is also advised. Without sh.exe some other features will not work properly, like git bisect and other.

Or if you like just run the below worked for MT 5.4dev and MT5.3 release/build, copy and paste the text over the contents of the buildwin64.sh file and run it within MSYS2 MinGW 64-bit shell:

Code: Select all

#!/bin/bash
set -e

CORE_GIT=https://github.com/minetest/minetest
CORE_BRANCH=master
CORE_NAME=minetest

#Minetest Game
MTG_GET_GAME=1 #Set to 0 to skip
MTG_GAME_GIT=https://github.com/minetest/minetest_game
MTG_GAME_BRANCH=master
MTG_GAME_NAME=minetest_game

#Voxelgarden
VOX_GET_GAME=1 #Set to 0 to skip
VOX_GAME_GIT=https://github.com/CasimirKaPazi/Voxelgarden
VOX_GAME_BRANCH=master
VOX_GAME_NAME=voxelgarden

dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ $# -ne 1 ]; then
	echo "Usage: $0 <build directory>"
	exit 1
fi
builddir=$1
mkdir -p $builddir
builddir="$( cd "$builddir" && pwd )"
packagedir=$builddir/packages
libdir=$builddir/libs

toolchain_file=$dir/toolchain_x86_64-w64-mingw32.cmake
irrlicht_version=1.8.4
ogg_version=1.3.2
vorbis_version=1.3.5
curl_version=7.65.3
gettext_version=0.20.1
freetype_version=2.10.1
sqlite3_version=3.27.2
luajit_version=2.1.0-beta3
leveldb_version=1.22
zlib_version=1.2.11

mkdir -p $packagedir
mkdir -p $libdir

cd $builddir

# Get stuff
[ -e $packagedir/irrlicht-$irrlicht_version.zip ] || wget http://minetest.kitsunemimi.pw/irrlicht-$irrlicht_version-win64.zip \
	-c -O $packagedir/irrlicht-$irrlicht_version.zip
[ -e $packagedir/zlib-$zlib_version.zip ] || wget http://minetest.kitsunemimi.pw/zlib-$zlib_version-win64.zip \
	-c -O $packagedir/zlib-$zlib_version.zip
[ -e $packagedir/libogg-$ogg_version.zip ] || wget http://minetest.kitsunemimi.pw/libogg-$ogg_version-win64.zip \
	-c -O $packagedir/libogg-$ogg_version.zip
[ -e $packagedir/libvorbis-$vorbis_version.zip ] || wget http://minetest.kitsunemimi.pw/libvorbis-$vorbis_version-win64.zip \
	-c -O $packagedir/libvorbis-$vorbis_version.zip
[ -e $packagedir/curl-$curl_version.zip ] || wget http://minetest.kitsunemimi.pw/curl-$curl_version-win64.zip \
	-c -O $packagedir/curl-$curl_version.zip
[ -e $packagedir/gettext-$gettext_version.zip ] || wget http://minetest.kitsunemimi.pw/gettext-$gettext_version-win64.zip \
	-c -O $packagedir/gettext-$gettext_version.zip
[ -e $packagedir/freetype2-$freetype_version.zip ] || wget http://minetest.kitsunemimi.pw/freetype2-$freetype_version-win64.zip \
	-c -O $packagedir/freetype2-$freetype_version.zip
[ -e $packagedir/sqlite3-$sqlite3_version.zip ] || wget http://minetest.kitsunemimi.pw/sqlite3-$sqlite3_version-win64.zip \
	-c -O $packagedir/sqlite3-$sqlite3_version.zip
[ -e $packagedir/luajit-$luajit_version.zip ] || wget http://minetest.kitsunemimi.pw/luajit-$luajit_version-win64.zip \
	-c -O $packagedir/luajit-$luajit_version.zip
#[ -e $packagedir/libleveldb-$leveldb_version.zip ] || wget http://minetest.kitsunemimi.pw/libleveldb-$leveldb_version-win64.zip \
#	-c -O $packagedir/libleveldb-$leveldb_version.zip
[ -e $packagedir/openal_stripped.zip ] || wget http://minetest.kitsunemimi.pw/openal_stripped64.zip \
	-c -O $packagedir/openal_stripped.zip


# Extract stuff
cd $libdir
[ -d irrlicht ] || unzip -o $packagedir/irrlicht-$irrlicht_version.zip -d irrlicht
[ -d zlib ] || unzip -o $packagedir/zlib-$zlib_version.zip -d zlib
[ -d libogg ] || unzip -o $packagedir/libogg-$ogg_version.zip -d libogg
[ -d libvorbis ] || unzip -o $packagedir/libvorbis-$vorbis_version.zip -d libvorbis
[ -d libcurl ] || unzip -o $packagedir/curl-$curl_version.zip -d libcurl
[ -d gettext ] || unzip -o $packagedir/gettext-$gettext_version.zip -d gettext
[ -d freetype ] || unzip -o $packagedir/freetype2-$freetype_version.zip -d freetype
[ -d sqlite3 ] || unzip -o $packagedir/sqlite3-$sqlite3_version.zip -d sqlite3
[ -d openal_stripped ] || unzip -o $packagedir/openal_stripped.zip
[ -d luajit ] || unzip -o $packagedir/luajit-$luajit_version.zip -d luajit
#[ -d leveldb ] || unzip -o $packagedir/libleveldb-$leveldb_version.zip -d leveldb

# Get minetest
cd $builddir
if [ ! "x$EXISTING_MINETEST_DIR" = "x" ]; then
	cd /$EXISTING_MINETEST_DIR # must be absolute path
else
	[ -d $CORE_NAME ] && (cd $CORE_NAME && git pull) || (git clone -b $CORE_BRANCH $CORE_GIT)
	cd $CORE_NAME
fi
git_hash=$(git rev-parse --short HEAD)

# Get minetest_game
if [ $MTG_GET_GAME = 1 ]; then
	if [ "x$NO_MINETEST_GAME" = "x" ]; then
		cd games
		[ -d $MTG_GAME_NAME ] && (cd $MTG_GAME_NAME && git pull) || (git clone -b $MTG_GAME_BRANCH $MTG_GAME_GIT)
		cd ..
	fi
else
	if [ "x$NO_MINETEST_GAME" = "x" ]; then
		cd games
			rm -rf $MTG_GAME_NAME
		cd ..
	fi
fi

# Get Voxelgarden
if [ $VOX_GET_GAME = 1 ]; then
	if [ "x$NO_VOXELGARDEN" = "x" ]; then
		cd games
		[ -d $VOX_GAME_NAME ] && (cd $VOX_GAME_NAME && git pull) || (git clone -b $VOX_GAME_BRANCH $VOX_GAME_GIT)
		cd ..
	fi
else
	if [ "x$NO_VOXELGARDEN" = "x" ]; then
		cd games
			rm -rf $VOX_GAME_NAME
		cd ..
	fi
fi

# Build the thing
[ -d _build ] && rm -Rf _build/
mkdir _build
cd _build
cmake .. \
	-G "MinGW Makefiles" \
	-DCMAKE_AR=/mingw64/x86_64-w64-mingw32/bin/ar \
	-DCMAKE_TOOLCHAIN_FILE=$toolchain_file \
	-DCMAKE_INSTALL_PREFIX=/tmp \
	-DVERSION_EXTRA=$git_hash \
	-DBUILD_CLIENT=1 -DBUILD_SERVER=0 \
	\
	-DENABLE_SOUND=1 \
	-DENABLE_CURL=1 \
	-DENABLE_GETTEXT=1 \
	-DENABLE_FREETYPE=1 \
	-DENABLE_LEVELDB=0 \
	\
	-DIRRLICHT_INCLUDE_DIR=$libdir/irrlicht/include \
	-DIRRLICHT_LIBRARY=$libdir/irrlicht/lib/Win64-gcc/libIrrlicht.dll.a \
	-DIRRLICHT_DLL=$libdir/irrlicht/bin/Win64-gcc/Irrlicht.dll \
	\
	-DZLIB_INCLUDE_DIR=$libdir/zlib/include \
	-DZLIB_LIBRARIES=$libdir/zlib/lib/libz.dll.a \
	-DZLIB_DLL=$libdir/zlib/bin/zlib1.dll \
	\
	-DLUA_INCLUDE_DIR=$libdir/luajit/include \
	-DLUA_LIBRARY=$libdir/luajit/libluajit.a \
	\
	-DOGG_INCLUDE_DIR=$libdir/libogg/include \
	-DOGG_LIBRARY=$libdir/libogg/lib/libogg.dll.a \
	-DOGG_DLL=$libdir/libogg/bin/libogg-0.dll \
	\
	-DVORBIS_INCLUDE_DIR=$libdir/libvorbis/include \
	-DVORBIS_LIBRARY=$libdir/libvorbis/lib/libvorbis.dll.a \
	-DVORBIS_DLL=$libdir/libvorbis/bin/libvorbis-0.dll \
	-DVORBISFILE_LIBRARY=$libdir/libvorbis/lib/libvorbisfile.dll.a \
	-DVORBISFILE_DLL=$libdir/libvorbis/bin/libvorbisfile-3.dll \
	\
	-DOPENAL_INCLUDE_DIR=$libdir/openal_stripped/include/AL \
	-DOPENAL_LIBRARY=$libdir/openal_stripped/lib/libOpenAL32.dll.a \
	-DOPENAL_DLL=$libdir/openal_stripped/bin/OpenAL32.dll \
	\
	-DCURL_DLL=$libdir/libcurl/bin/libcurl-4.dll \
	-DCURL_INCLUDE_DIR=$libdir/libcurl/include \
	-DCURL_LIBRARY=$libdir/libcurl/lib/libcurl.dll.a \
	\
	-DGETTEXT_MSGFMT=`which msgfmt` \
	-DGETTEXT_DLL=$libdir/gettext/bin/libintl-8.dll \
	-DGETTEXT_ICONV_DLL=$libdir/gettext/bin/libiconv-2.dll \
	-DGETTEXT_INCLUDE_DIR=$libdir/gettext/include \
	-DGETTEXT_LIBRARY=$libdir/gettext/lib/libintl.dll.a \
	\
	-DFREETYPE_INCLUDE_DIR_freetype2=$libdir/freetype/include/freetype2 \
	-DFREETYPE_INCLUDE_DIR_ft2build=$libdir/freetype/include/freetype2 \
	-DFREETYPE_LIBRARY=$libdir/freetype/lib/libfreetype.dll.a \
	-DFREETYPE_DLL=$libdir/freetype/bin/libfreetype-6.dll \
	\
	-DSQLITE3_INCLUDE_DIR=$libdir/sqlite3/include \
	-DSQLITE3_LIBRARY=$libdir/sqlite3/lib/libsqlite3.dll.a \
	-DSQLITE3_DLL=$libdir/sqlite3/bin/libsqlite3-0.dll #\
	#\
	#-DLEVELDB_INCLUDE_DIR=$libdir/leveldb/include \
	#-DLEVELDB_LIBRARY=$libdir/leveldb/lib/libleveldb.dll.a \
	#-DLEVELDB_DLL=$libdir/leveldb/bin/libleveldb.dll

mingw32-make package -j$(nproc)

cd _CPack_Packages/win64/ZIP/
cp /mingw64/bin/libgcc_s_seh-1.dll minetest-*/bin
cp /mingw64/bin/libstdc++-6.dll minetest-*/bin
cp /mingw64/bin/libwinpthread-1.dll minetest-*/bin
zip -ur minetest-*.zip minetest-*
cp minetest-*.zip ../../../

echo -n "End of compilation"; date -R

exit 0
# EOF 

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest