Skip to content

Commit

Permalink
Guide for compiling a Windows version using Visual Studio.
Browse files Browse the repository at this point in the history
Experimental guide for compiling with a cygwin / mingw32 version.
  • Loading branch information
Alatun-Rom authored and cvuchener committed Apr 25, 2019
1 parent d2a81ba commit e6995fe
Show file tree
Hide file tree
Showing 4 changed files with 204 additions and 1 deletion.
112 changes: 112 additions & 0 deletions BUILDING.experimental
@@ -0,0 +1,112 @@
Experimental build guides using cygwin: https://www.cygwin.com

Install cygwin and select these packages:
cmake
gcc-g++
git
make
libQt5Quick-devel
libQt5Svg-devel
xinit
xorg-server

Checkout the DwarfTherapist sources the Linux way.

### Cygwin cross compile for windows using mingw ###

1.) Install these additional cygwin packages:
mingw64-x86_64-gcc-g++-7.4.0.1
mingw64-x86_64-qt5-base-5.9.4-1
mingw64-x86_64-qt5-quickcontrols-5.9.4-1
mingw64-x86_64-qt5-svg-5.9.4-1

2.) Compile
Navigate to you dwarf therapist source directory and type the following commands

mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=../Toolchain-mingw32.cmake ../
make

3.) Prepare DT run directory
Create a directory "run" and copy "DwarfTherapist.exe" from the
build directory to the run directory.

Copy these files from "/usr/x86_64-w64-mingw32/sys-root/mingw" to the run directory.

iconv.dll
libbz2-1.dll
libfreetype-6.dll
libgcc_s_seh-1.dll
libglib-2.0-0.dll
libharfbuzz-0.dll
libintl-8.dll
libpcre-1.dll
libpcre2-16-0.dll
libpng16-16.dll
libstdc++-6.dll
libwinpthread-1.dll
Qt5Core.dll
Qt5Gui.dll
Qt5Network.dll
Qt5Qml.dll
Qt5Widgets.dll
zlib1.dll

Create a subdir called "platforms" in the "run directory" and copy "qwindows.dll"
from /usr/x86_64-w64-mingw32/sys-root/mingw/lib/qt5/plugins/platforms/
to the platforms directory below "run".

Copy share/memory_layouts to the DT run directory.

4.) Run DT native from windows
does connect and can load a fortress

### Cygwin version: ###

This version cannot run as a native windows application, but must be run using
an X-Server from cygwin. I just did it for fun. It requires to change some of
the Qt5 Library header files. So if you update your Qt packages this changes may
get lost or cause other problems.

1.) Modify files:

Modify "/usr/include/qt5/QtGui/qwindowdefs_win.h" (next to the end)
// Maybe this is a bug in QT5 sources?
....
#ifndef _HRESULT_DEFINED
#ifdef __CYGWIN__ // # ADDED
typedef int HRESULT; // # ADDED
#else // # ADDED
typedef long HRESULT;
#endif // # ADDED
#endif
...

Modify "CMakeLists.txt" from DwarfTherapist and add a "CYGWIN" option.
It is important to have the opton "Q_OS_WIN" defined. Otherwise it seems
Qt5 is assuming a different platform which causes compile errors.

...
set(EXE_NAME "DwarfTherapist")
if(WIN32 OR CYGWIN)
if(CYGWIN)
add_definitions(-DQ_OS_WIN)
endif()
...

2.) Compile
Navigate to you dwarf therapist source directory and type the following commands

mkdir build
cd build
cmake ../
make

3.) Prepare DT directory
Copy Memory_layouts to
~/.local/share/Dwarf\ Therapist

4.) Run DT
startx
./DwarfTherapist.exe
76 changes: 75 additions & 1 deletion BUILDING.md
Expand Up @@ -13,7 +13,75 @@ For building the manual, see the README in the [Manual repository](https://githu
Windows
-------

TODO
### Visual studio version ###

1.) Download Microsoft Visual Studio

https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2017

Install "Tools for Visual Studio 2019" and
select these additional options:

- C++ Cmake Tools for Windows
- MSVC v141 - VS2017 C++ x64/x86 build Tools

2.) Download Qt Creator & Libraries

http://download.qt.io/official_releases/qt/5.9/5.9.7/qt-opensource-windows-x86-5.9.7.exe

Start the installer and select this option:

- MSVC 2017 64-bit

Note the path where you are installing this, because this will be used later. The default path is "C:\Qt\Qt5.9.7". I did install it to "E:\Qt\Qt5.9.7". So if you see this path prefix below you should change this according to your install path.

3.) Download git for windows

https://gitforwindows.org

Install and keep the default options unless you know what to do.

Open a git console and navigate to a directory where you would like to download the sources of DT. (e.g. "E:\dev" ). In the git console you need to use unix path style. The path "E:\dev" will be "/e/dev" in the git console window.

4.) Check out the sources for Dwarf Therapist

Type the cmd below in the git console:

git clone https://github.com/Dwarf-Therapist/Dwarf-Therapist.git

This will create a new directory named "Dwarf-Therapist" in the current directory. In our example the path of the sources will now be "E:\dev\Dwarf-Therapist". This path will be used for the commands in the next sections. Adapt the path accordingly, if you are using a different path.

5.) Compile

Open the "x64 Native Tools Command Prompt for VS 2019" (Visual Studio 2019 - Visual Studio Tools - VC)

Navigate to the DT source directory and type the commands below:

mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH=E:/Qt/Qt5.9.7/5.9.7/msvc2017_64 -G "Visual Studio 15 2017 Win64" ..\
MSBuild.exe DwarfTherapist.sln /p:Configuration=Release

Troubleshooting:

Cmake is being called with a CMAKE_PREFIX_PATH using forward slashes "/" because this is the internal path notation for cmake. Cmake can deal with backward slashes, but only when it is running in command mode. When running in server mode it ONLY works with forward slashes. If you are using an IDE like "Visual Studio Code" cmake will be set to run in server mode and backward slashes will cause errors like "invalid escape \Q".


6.) Create a directory to collect all files for running Dwarf Therapist

After the compilation has been completed successfully, you should find a DwarfTherapist.exe in the "Release" folder which has been created in the build folder.

Now type these commands, assuming you are still in the build folder.

mkdir ..\run
copy Release\DwarfTherapist.exe ..\run
E:\Qt\Qt5.9.7\5.9.7\msvc2017_64\bin\windeployqt.exe ..\run
mkdir ..\run\data
xcopy /s ..\share\* ..\run\data

The folder "run" should now contain all files needed to run DwarfTherapist.



Linux
-----
Expand Down Expand Up @@ -83,3 +151,9 @@ Build using make:

TODO


Cygwin / Mingw
--------------

There is a short guide for building a version for Cygwin and
cross compiling using mingw in BUILDING.experimental.
Empty file modified CMakeLists.txt 100644 → 100755
Empty file.
17 changes: 17 additions & 0 deletions Toolchain-mingw32.cmake
@@ -0,0 +1,17 @@
# the name of the target operating system
SET(CMAKE_SYSTEM_NAME Windows)

# which compilers to use for C and C++
SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
SET(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)

# here is the target environment located
SET(CMAKE_FIND_ROOT_PATH /lib/gcc/x86_64-w64-mingw32/7.4.0/ /usr/x86_64-w64-mingw32/sys-root/mingw )

# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

0 comments on commit e6995fe

Please sign in to comment.