Page 1 of 1

Working latest instructions on how to compile on windows

PostPosted: Sat Feb 02, 2013 19:22
by Neuromancer
I couldn't find the best and latest set of instructions on how to compile minetest in windows.
-BG Smith's first post?
-A later post in that same thread?
-The readme included with the source download?
None worked for me.

I took another crack at this and documented the process in a more step by step way. And thanks to a little help, I got it working!

Steps:
* If you haven't already, install OpenAl on your machine.
* Download and Install CMake: http://www.cmake.org/cmake/resources/software.html
* Download and Install MinGW or Visual Studio C++ express 2008.
http://www.mingw.org/
http://msdn.microsoft.com/en-us/vstudio/default
* Create a directory called DIR hereafter in which you will operate.
example: C:\Users\x\Documents\Projects\Minetest44
*Per xyz, you can use any version of irrlicht you want. But for reference Minetest .44 uses Irrlicht 1.7.2. If
you want the exact version that the current game is using, just compare the filesizes of irrlict.dll
-- Go to the Irrlicht SDK Download page and dowload it http://irrlicht.sourceforge.net/downloads.html
* Copy irrlicht.zip to DIR and extract it into there.
("extract here", not "extract to packagename/")
* Go to http://www.winimage.com/zLibDll/index.html
* Download zlib-1.2.5.tar.gz - sources of zlib
* Copy it into DIR.
* extract into DIR. ("extract here", not "extract to packagename/")
* In DIR create new folder zlib125dll.
* Go to http://www.winimage.com/zLibDll/index.html
* Download zlib125dll.zip - pre-built zlib DLL. Copy into DIR\zlib125dll folder.
* extract into DIR\zlib125dll. ("extract here", not "extract to packagename/")

* Go to http://www.xiph.org/downloads/
* Download libvorbis-1.3.3.zip
* Copy it into DIR
I'm not sure about the following step. It does not match the final directory structure.
Can anyone confirm if the following step is correct?
* extract into DIR. ("extract here", not "extract to packagename/")

*Go to http://www.dll-files.com/dllindex/dll-files.shtml?libvorbisfile
* Click on "Download zip-file" button.
* Copy to DIR.
* extract into DIR. ("extract here", not "extract to packagename/")
The problem here is that the libvorbisfile.dll from this download is 118k, yet the libvorbisfile.dll included with
compiled minetest is 29kb. I say use the 29kb livorbisfile.dll included with the game. Copy that into dir.
Can anyone confirm if this is right?

* Go to http://www.xiph.org/downloads/
* Download libogg-1.3.0.zip
* Copy it into DIR
* extract into DIR. ("extract here", not "extract to packagename/")
===================================================================================================
*Now we need a little linking file called libvorbisfile.lib, and you will have to do some work to get it.
*You can compile without this part, but you will need to uncheck Enable sounds in Cmake later on.
-Go to C:\Users\x\Documents\Projects\Minetest44\libogg-1.3.0\win32\VS2008 & double click on libogg_static.sln to
open it in Visual Studio 2008.
-right click on the solution and click build solution.
-build libogg_dynamic.sln using the same 2 steps above.

-Go to C:\Users\x\Documents\Projects\Minetest44\libvorbis-1.3.3\win32\VS2008 & double click on vorbis_static.sln to
open it in Visual Studio 2008.
-right click on the libvorbis_static project, then select properties.
-drill down to Configuration Properties, C/C++, General
-click on the box to the right of Additional Include Directories, and click "..."
-click on the folder with a star on it to insert a new line
-click on the "...".
-navigate to something like C:\Users\x\Documents\Projects\Minetest44\libogg-1.3.0\include
-do the same for the rest of the projects in this solution.
-for 2 projects vorbisdec and vorbisenc right click Project> Properties> Linker> General>Additional Library
Directories setting and add C:\Users\x\Documents\Projects\Minetest44\libogg-1.3.0\win32\VS2008\Win32\Debug
-right click on the solution and click compile.

-Go to C:\Users\x\Documents\Projects\Minetest44\libvorbis-1.3.3\win32\VS2008 & double click on vorbis_dynamic.sln to
open it in Visual Studio 2008.
-for all 4 projects right click Project> Properties> Linker> General>Additional Library
Directories setting and add C:\Users\x\Documents\Projects\Minetest44\libogg-1.3.0\win32\VS2008\Win32\Debug
-right click on the solution and click compile.

if you get an error like this one:
Error 2 error LNK2001: unresolved external symbol _analysis_output_always vorbis.def
open vorbis.def and look for the line where _analysis_output_always is specified, and put a semi colon in front of it. that'll comment out the line.
The function definition itself is normally commented out in the code, so that's why you're having this problem.
then place each file in it's place.
==============================================================================

* Go to http://minetest.net/download.php
* Scroll down to sourcecode
* In this case I'm downloading Stable minetest-0.4.4 zip, but what version you d/l is going to change
based on your circumstances.
* Copy to your DIR.
* extract into DIR. ("extract here", not "extract to packagename/")
* rename extracted folder to "minetest"

I'm sure the below is wrong, I think you just add this after you are done compiling, but I'll try this anyway.
* In the DIR folder make a folder called games
* Go to http://minetest.net/download.php
* Scroll down to sourcecode
* In this case I'm downloading Stable minetest_game-0.4.4 zip, but what version you d/l is going to change
based on your circumstances.
* Copy to your DIR\games folder.
* extract into DIR\games folder. ("extract here", not "extract to packagename/")
* rename extracted folder to "minetest_game"

* copy the libogg.dll & libvorbis.dll from the compiled minetest\bin folder to DIR

Here's what BJSmith's documentation said I should see. Anything with an X before it is a folder that I don't have after
following the steps above.
-----------------
+ DIR
X- oalinst.exe
- zlib-1.2.5.tar.gz
X- zlib125dll.zip
- irrlicht-1.7.2.zip
- libvorbis-1.3.3.zip
- libogg-1.3.0.zip
- 110214175330.zip (or whatever, this is the minetest source)
+ zlib-1.2.5
- zlib.h
+ win32
...
+ zlib125dll
- readme.txt
+ dll32
...
+ irrlicht-1.7.2
+ lib
+ include
...
HERE + libvorbis-1.3.3.zip
+ lib
+ include
...
HERE + libogg-1.3.0.zip
+ lib
+ include
...
X+ gettext (optional)
+bin
+include
+lib
+ minetest
+ src
+ doc
- CMakeLists.txt
...

I had some extra folders/files that weren't mentioned in BJSmith's Documentation:
libvorbisfile.zip
libvorbisfile.dll
libvorbis-1.3.3
libogg-1.3.0
libogg.dll
games
+readme.zip
-----------------
- create folder DIR\minetest-build
- Start up the CMake GUI
- Select "Browse Source..." and select DIR/minetest
- Now, if using MSVC:
- Select "Browse Build..." and select DIR/minetest-build
- Else if using MinGW:
- Select "Browse Build..." and select DIR/minetest
- Select "Configure"
- Select your compiler (Visual Studio 9 2008 if using VS Express C++ 2008.
- click finish
- It will warn about missing stuff, ignore that at this point. (later don't)
- Make sure the configuration is as follows
(note that the versions may differ for you)
(note you should create the folders below if they do not exist):
-------------------------------------------------------------
BUILD_CLIENT [X]
BUILD_SERVER [ ]
CMAKE_BUILD_TYPE Release
CMAKE_INSTALL_PREFIX DIR/minetest-install
IRRLICHT_SOURCE_DIR DIR/irrlicht-1.7.2
RUN_IN_PLACE [X]
WARN_ALL [ ]
ZLIB_DLL DIR/zlib125dll/dll32/zlibwapi.dll
ZLIB_INCLUDE_DIR DIR/zlib-1.2.5
ZLIB_LIBRARIES DIR/zlib125dll/dll32/zlibwapi.lib
HERE LIBVORBIS_INCLUDE_DIR DIR/libvorbis-1.3.3/include
* VORBIS_LIBRARY DIR/libvorbis-1.3.3/win32/VS2008/Win32/Debug/libvorbis.lib
* VORBIS_INCLUDE_DIR DIR/libvorbis-1.3.3/include
*ORBISFILE_LIBRARY DIR/libvorbis-1.3.3/win32/VS2008/Win32/Debug/libvorbisfile.lib
HERE LIBOGG_INCLUDE_DIR DIR/libogg-1.3.0/include
* OGG_LIBRARY DIR/libogg-1.3.0/win32/VS2008/Win32/Debug/libogg.lib
GETTEXT_BIN_DIR DIR/gettext/bin
GETTEXT_INCLUDE_DIR DIR/gettext/include
GETTEXT_LIBRARIES DIR/gettext/lib/intl.lib
GETTEXT_MSGFMT DIR/gettext/bin/msgfmt
OPENAL_INCLUDE_DIR=C:/Program Files/OpenAL 1.1 SDK/include
OPENAL_LIBRARY=C:/Program Files/OpenAL 1.1 SDK/libs/Win32/OpenAL32.lib
- Hit "Configure"
- Hit "Configure" once again 8)
- If something is still coloured red, you have a problem.
- Hit "Generate"
If using MSVC:
- Open the generated minetest.sln
- The project defaults to the "Debug" configuration. Make very sure to
select "Release", unless you want to debug some stuff (it's slower
and might not even work at all)
- Build the ALL_BUILD project
- Build the INSTALL project
- You should now have a working game with the executable in
DIR/minetest-install/bin/minetest.exe
- Additionally you may create a zip package by building the PACKAGE
project.
If using MinGW:
- Using the command line, browse to the build directory and run 'make'
(or mingw32-make or whatever it happens to be)
- You may need to copy some of the downloaded DLLs into bin/, see what
running the produced executable tells you it doesn't have.
- You should now have a working game with the executable in
DIR/minetest/bin/minetest.exe

I compiled using VS express c++ 2008. I got the error
4>..\..\minetest\src\serialization.cpp(26) : fatal error C1083: Cannot open include file: 'zlib.h':
No such file or directory
I copied DIR\zlib-1.2.5\ zlib.h & zconf.h to DIR\minetest\src and the error went away.

You now should have a shiny minetest.exe sitting in
DIR\minetest\bin\Release\
Go ahead and copy it over the minetest.exe that is sitting in your usual install (hopefully same version you
just compiled) and it should contain any changes you make to the cpp files.
Or better yet in your DIR\minetest-install directory you should have a full install of the game. I believe that
the game folder still needs some tweaking, like being overwritten by the minetest_game folder you downloaded.


Windows releases of minetest are built using a bat script like this:
--------------------------------------------------------------------

set sourcedir=%CD%
set installpath="C:\tmp\minetest_install"
set irrlichtpath="C:\tmp\irrlicht-1.7.2"

set builddir=%sourcedir%\bvc10
mkdir %builddir%
pushd %builddir%
cmake %sourcedir% -G "Visual Studio 10" -DIRRLICHT_SOURCE_DIR=%irrlichtpath% -DRUN_IN_PLACE=1 -DCMAKE_INSTALL_PREFIX=%installpath%
if %errorlevel% neq 0 goto fail
"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" ALL_BUILD.vcxproj /p:Configuration=Release
if %errorlevel% neq 0 goto fail
"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" INSTALL.vcxproj /p:Configuration=Release
if %errorlevel% neq 0 goto fail
"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" PACKAGE.vcxproj /p:Configuration=Release
if %errorlevel% neq 0 goto fail
popd
echo Finished.
exit /b 0

:fail
popd
echo Failed.
exit /b 1


exit /b 1 This looks interesting: https://github.com/celeron55/minetest/blob/master/util/buildbot/buildwin32.sh

PostPosted: Sat Feb 02, 2013 19:24
by PilzAdam
Steps:
1) Aks PilzAdam to cross-compile.
2) Wait.
3) Win.

PostPosted: Sat Feb 02, 2013 19:29
by Neuromancer
PilzAdam wrote:Steps:
1) Aks PilzAdam to cross-compile.
2) Wait.
3) Win.

That's great for folks who just want to play the latest version of the game. What about the folks that actually want to do more than just write mods, actually want to improve the engine. This first hump of getting Minetest to compile on windows is a rough one to get over. If we make that easy, and let people play around in the code, trying different things, who knows what new ideas to improve Minetest might happen. An army of Lua coders is not enough. We need people learning C++, and Irrlicht etc. Plus it's just fun to learn new things.

PostPosted: Sat Feb 02, 2013 19:55
by Mito551
What about virtual machine?

PostPosted: Sun Feb 03, 2013 02:37
by Neuromancer
I may be close. Just 1 fatal error.

I got 1>C:\Users\x\Documents\Projects\Minetest44\libvorbisfile.dll : fatal error LNK1107:
invalid or corrupt file: cannot read at 0x2B8

PostPosted: Sun Feb 03, 2013 03:42
by rarkenin
That's cause you want a .LIB file, not a .DLL. Try downloading libvorbis sources and using the compile option for a static library. Or, it might already be in the lib or bin directories of the archive file (zip file or tarball) you download.

PostPosted: Sun Feb 03, 2013 14:25
by Neuromancer
rarkenin wrote:That's cause you want a .LIB file, not a .DLL. Try downloading libvorbis sources and using the compile option for a static library. Or, it might already be in the lib or bin directories of the archive file (zip file or tarball) you download.

The problem with that is there doesn't seem to be a libvorbis*.lib file anywhere. Can anyone confirm, do we need to find a libvorbisfile.lib?

PostPosted: Sun Feb 03, 2013 14:33
by xyz
Neuromancer wrote:The problem with that is there doesn't seem to be a libvorbis*.lib file anywhere.   Can anyone confirm, do we need to find a libvorbisfile.lib?

You should compile it to get a libvorbisfile.lib.

Neuromancer wrote:(Can't you folks just tell us what version of irrlicht to use? :)

Any.

PostPosted: Sun Feb 03, 2013 15:14
by Topywo

PostPosted: Sun Feb 03, 2013 22:14
by Neuromancer
Thanks to all, especially xyz! Your help enabled me to actually finally get a Windows compile working! Enjoy the docs everyone!

PostPosted: Mon Feb 04, 2013 00:40
by Neuromancer
Mito551 wrote:What about virtual machine?

Not sure I understand your question. Are you looking for instructions on how to compile for a virtual machine?

PostPosted: Mon Feb 04, 2013 13:58
by PilzAdam
This should go into Unofficial Engine development.

PostPosted: Sun May 12, 2013 21:51
by sdzen
PilzAdam wrote:This should go into Unofficial Engine development.

correction. this should go to the wiki and the readme.txt, this is much more in depth then the default instructions

PostPosted: Sun May 12, 2013 23:21
by CryAngel
Curl missed here?