Building QSAS on Windows
May 2015; updated September 2015; tweaked re new MSYS install Oct 2015
Apr 2016 moved export mingw64/bin into PATH to before cdf build
SJS

The following provides guidance about building QSAS on windows. It uses msys2 and mingw64, and is geared toward 64-bit architecture, although it should be possible to follow parallel steps to build a 32-bit version. It should also be possible to get the mingw64 cross-compilers to build a 32-bit version without installing a 32-bit toolchain. This all looks longer than it really is, and once everything is setup, re-building is relatively painless.

1	Fetch msys2 from http://sourceforge.net/p/msys2/wiki/MSYS2%20installation/ and install. As per those instructions perform  one of the following IN STRICT ORDER:

(a) launch msys2_shell.bat (MSYS2 Shell from the Start Menu), then
	update-core
	[restart msys2 shell]
	pacman -Su

(b) [the old way prior to the update-core script]
launch msys2_shell.bat
pacman -Sy
pacman --needed -S bash pacman pacman-mirrors msys2-runtime
Exit and restart msys2_shell.bat to pick up those changes (if any)
pacman -Su

2	Now we'll fetch everything else we need, following instructions from wiki.qt.io/MSYS2 (which also includes those instructions in (1)

pacman -S base-devel git mercurial cvs wget p7zip
pacman -S perl ruby python2 mingw-w64-i686-toolchain mingw-w64-x86_64-toolchain
pacman -S mingw-w64-i686-qt-creator mingw-w64-x86_64-qt-creator

(if you're just putting together the 64-bit versions, you can omit all the things with "i686" in them, as these are the 32-bit versions).

2a	In your msys64/home/<username> directory, edit your .profile to add /usr/bin and ...cdf-dist/bin to your PATH, e.g., mine are:

export PATH=/usr/bin:/mingw64/bin:${PATH}

3	Fetch the cdf src from http://cdf.gsfc.nasa.gov/html/sw_and_docs.html (the binary distribution isn't compatible with msys/mingw AFAICT). You can read how to build it by following the simple INSTALL instructions, although all you really need to do is cd into the top-most cdf-dist directory and perform:

make OS=mingw ENV=gnu SHARED=yes  CURSES=no all
make test
make install

4	In your msys64/home/<username> directory, edit your .profile to add /usr/bin and ...cdf-dist/bin to your PATH, e.g., mine are:

export PATH=/usr/bin:/mingw64/bin:${PATH} [if not done previously in 2a]
export PATH=/home/steve/cdf36_0-dist/bin:/home/steve/cdf36_0-dist/lib:${PATH}

and rename .bash_profile to something else so you're sure to pick up your own simple .profile (this is what I do, but gurus will know better).

5	Unpack the QSAS source distribution if you haven't already, then cd to its bin directory.

6	Edit the build_win script to replace the locations at the very top by the locations of your qsas, cdf, mingw64, etc. Note that mingw64 puts the Qt libraries together in mingw64/lib and mingw64/bin, but the includes are all in sub-directories in mingw64/include

7	Perform:

./build_win empty     [to clear out any libraries and compiled code]
./build_win qsas      [this is a good time to make a cup of tea]

8	You can run QSAS from this build directory, but if you want to move it or give a copy to someone else, edit the section in the build_win script dealing with RELEASES and identify a location for a self-contained QSAS; this will also include copies of all the mingw64 and Qt libraries. Then perform

./build_win release

This will actually re-build QSAS before installing it in your RELEASE directory

9	Edit the QSAS.bat and/or the QSAS_win scripts to point to your installation.

10	Create a shortcut for QSAS.bat and put it on your desktop or pin to your Start Menu. It is also possible with some trickery to get it to your Quicklaunch taskbar. See below if interested.

11	Double-click on QSAS.bat, or better, execute QSAS_win from a command line - the .bat is executed simply by typing its name after the prompt. That way, you'll see any run-time errors. If QSAS compiled correctly, these are almost always related to path issues in your script.

12	QSAS ships with a sample session under File->Restore Session... This will get you started. There is a substantial amount of information in the Help pages. If that doesn't help, contact csc-support@imperial.ac.uk

SJS
25 May 2015

-------------------------

To pin QSAS.bat to your taskbar:

a)Make a shortcut to your QSAS.bat file. Keep it somewhere
b) Make a shortcut to your shortcut. In its properties, add explorer in front of the path, e.g.,

explorer C:\users\....QSAS.bat

c) Now you can drag it and pin it to the taskbar, but it won't run
d) Go to c:\users\<yourusername>\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\Taskbar
e) Right click on the QSAS.bat shortcut and reset its target back to:

C:\users\....QSAS.bat

(sigh)