# Installation

Linux installation notes are now on the downloads page
[DEV] Some further steps are required to install IUP on Linux, see demo\pGUI\lnx\installation.txt
Phix is now (since it is now around 38.5MB) distributed in five parts:

- phix.{version}.setup.exe - a standard Windows installer,
- phix.{version}.1.zip - IUP dlls,
- phix.{version}.2.zip - bench and 95% of demo,
- phix.{version}.3.zip - docs.
- phix.{version}.4.zip - Phix.chm.

The setup.exe unpacks to a directory (the default is C:\Program Files (x86)\Phix, less the " (x86)" on 32-bit machines) and runs ppw.bat.
Then, via demo\pGUI\pdemo\installation.e, it automatically downloads (unless it can find them) and extracts the three .zip files.
During installation, it may display the message "Aside: phix.N.N.N.setup.exe not found", which means it cannot check whether you also (manually) downloaded phix.N.N.N.1.zip etc to that same directory, and will therefore automatically download them into the installation directory.
Should you be attempting an offline installation, you may wish to know that it checks for it/them in C:\Downloads, %ALLUSERSPROFILE%, %APPDATA%, %LOCALAPPDATA%, %PUBLIC%, %USERPROFILE%, %TEMP%, and %PHIXSETUP% (obviously the latter should be explicitly set as part of your installation process when none of the others are acceptable).
On Linux it checks ".", %HOME%, and %PHIXSETUP%.
The file Phix/sfx/phix.version.txt is used to determine whether additional files have already been successfully downloaded/extracted/deleted (using a leading Y/N: on each file).
It is automatically re-created (with Ns, by pw pdemo -settings) if absent, and can be manually edited (to Ys) if for any reason you had to perform the download/extract manually.
The secondary installation may also display several other messages:
sfx directory not found - the phix.{version}.setup.exe did not complete?
current directory does not end in Phix - running in the wrong directory?
Download errors are assumed to be self explanatory.
Extract errors may (for now) require manual deletion of bad zip files.
Alternatively you can unpack the contents manually using say 7-zip and edit/run that batch file or the following commands (from ppw.bat) by hand:

            pw -p         :: (create p.exe from pw.exe)
            :: recompilation from sources (next line) is optional
            ::p -cp             :: (creates p.exe and pw.exe)
            pw pdemo -settings

When installed, the Phix directory looks something like this (on Windows):

     \Phix
        p.exe           (the console version of Phix)
        p.exw           (and other compiler sources)
        pdemo.exw       (stub to demo\pGUI\pdemo.exw)
        phixzip.exw     (repackage script)
        ppw.bat         (setup script)
        pw.exe          (the gui version of Phix)
        readme.txt      (release notes)
        \bench          (performance tests [if absent, .1.zip failed])
        \builtins       (standard include files, e.g. database.e)
        \demo           (various example programs including pGUI and Edix)
        \docs           (these files [if absent, .2.zip failed])
        \sfx            (phix7zip.lst, details the full distribution set)
        \test           (tests to be run via p -test)

Installation does not modify anything in the system registry, nor does it create any start menu or desktop shortcuts, or set the PATH environment variable. The distribution does however include the program pdemo.exw which has a setup tab to modify the registry, and can be run by either opening a command prompt in the directory where Phix was installed and entering "pw pdemo" (without the quotes), or double clicking on pw.exe in that directory and entering pdemo to the prompt. That program opens with the demo tab showing, feel free to experiment with a few of those before visiting the settings tab. On that settings tab you can also "micro-manage" things, creating both a setup.reg and an undo.reg that you can use to vet/modify or cleanup all settings, for more details refer to the somewhat excessively verbose details that appear when you click on the Help button, or just accept my judgement and hit "OK".
Personally I never set PATH, EUINC, or EUDIR, though they can be used if you want. (If you do not know what I mean by that, you can safely ignore it.)
On a fresh (win7) machine I normally create a start menu entry as follows:

- Right click on Start/All Programs/Accessories/Command Prompt and select the "Pin to Start Menu" option, or if you prefer drag it onto the desktop with the right mouse button and select "Create shortcuts here".
- Right click on the new menu item or icon and select properties.
- Change the start directory to `C:\Program Files (x86)\Phix`, or wherever you installed Phix, and change the description to something more meaningful than "Command Prompt", even if it is just "Command Prompt (Phix)".
- Test it by clicking on the menu item/icon just created and entering "p", if everything is installed correctly and working you should see something similar to:

              Phix hybrid interpreter/compiler.

              Version 0.6.4  Copyright Pete Lomax 2006..2014

              Enter ? for options or filename to execute:

  Enter "-test" (or "p -test" to start with) and it should run through 63 tests and if all goes well end by displaying something like "All tests completed successfully, 3.31 seconds". Press escape or return and Phix will terminate; then enter "exit" or click on the usual top right "X" if you want to close the (MS-DOS) Command Prompt window, though normally I leave mine open all day.

Phix can be recompiled at a command prompt simply by typing 'p -c p' (or './p -c p' on Linux), the result should look something like this:
A 'four round' approach makes it far harder to shoot myself in the foot. That 8 seconds has probably crept over 10 by now. The first three lines can safely be ignored unless and until you start getting 'in use' error messages, as of course can all of that output but not any other error messages which might appear.
For comparison the latest Euphoria build instructions for Windows can be found here http://openeuphoria.org/wiki/view/Compiling41windows.wc and for Linux here http://openeuphoria.org/wiki/view/How%20to%20Compile%20Open%20Euphoria%20On%20Linux.wc and I suspect the same or worse is true for other programming languages; few if any can be rebuilt as easily or as quickly as Phix.
One of my favourite parlour tricks is to show 'p -cp' rebuild the compiler itself in around 8 seconds, then show 'p p p p p p p p -cp' stack 7 interpreted copies of itself on top of one another, and apart from ten or fifteen seconds longer to get started, it still completes in around the same time. Admittedly the timings shown on screen are from the rightmost "p -cp" only and would not agree with someone using a manual stopwatch, but all good fun and certainly several times faster than most would expect. Plus, in our little stack of eight compilers, the very top/last copy actually replaces the very bottom/first one!
I should note that in some (rare) cases 'p p -cp' may manage to 'leap-frog' a 'chicken and egg' situation that 'p -cp' cannot cope with, especially if you have tried to make too many changes to too many things in one step. If neither 'p -cp' nor 'p p -cp' can cope, you may need to re-work the changes into smaller discrete steps, sometimes with the 'old-style' and 'new-style' temporarily co-existing.
I do not currently ship a 64-bit version of Phix. For that you need to insert "format PE64" or "format ELF64" at the start of p.exw and recompile (p -cp). You may also want to copy/move from C:\Program Files (x86)\Phix to C:\Program Files\Phix. If all goes smoothly, the entire process can easily be completed in 30 seconds.
Optional system tweak: Recent Versions of Windows have WER (Windows Error Reporting) enabled by default. Without commenting on whether or not you may find that useful with released software, it is highly unlikely that going online to check for solutions to some problem in a program you have only just compiled is ever going to help. Should this become annoying, you might like to apply the following quick change to settings: On Windows 7, click on start and type "WER" (without the quotes) into the search box, select "Choose how to check for solutions", click on "Change report settings for all users" and instead of "Automatically check for solutions(recommended)" select "Each time a problem occurs, ask me before checking for solutions". As a bonus, you will get low-level diagnostics (code/address) via a "more details" button, that otherwise you would have to dig deep for. In truth, Phix should always catch errors before they ever get near WER, but that might cease to be true whilst making significant changes to the compiler itself.
See also Phix\sfx\phix\readme.txt if you want to set up some start menu entries.