# Julia on Windows This file describes how to install, or build, and use Julia on Windows. For more general information about Julia, please see the [main README](https://github.com/JuliaLang/julia/blob/master/README.md) or the [documentation](https://docs.julialang.org/). ## General Information for Windows ### Unicode font support The built-in Windows fonts have rather poor coverage of the Unicode character space. The free [`DejaVu Sans Mono`](http://dejavu-fonts.org/) font can be used as a replacement font in the Windows console. Since Windows 2000, simply downloading the font and installing it is insufficient, since Windows keeps a list of approved fonts in the registry. Instructions for adding fonts to the terminal are available at [this answer on superuser.com](https://superuser.com/a/5079) Additionally, rather than sticking with the default command prompt, you may want to use a different terminal emulator program, such as [Conemu](https://code.google.com/p/conemu-maximus5/) or [Mintty]( https://code.google.com/p/mintty/) (note that running Julia on Mintty needs a copy of `stty.exe` in your `%PATH%` to work properly). Alternatively, you may prefer the features of a more full-function IDE, such as [Juno](http://junolab.org), [Sublime-IJulia](https://github.com/quinnj/Sublime-IJulia), or [IJulia](https://github.com/JuliaLang/IJulia.jl). ### Line endings Julia uses binary-mode files exclusively. Unlike many other Windows programs, if you write `\n` to a file, you get a `\n` in the file, not some other bit pattern. This matches the behavior exhibited by other operating systems. If you have installed msysGit, it is suggested, but not required, that you configure your system msysGit to use the same convention: ```sh git config --global core.eol lf git config --global core.autocrlf input ``` or edit `%USERPROFILE%\.gitconfig` and add/edit the lines: ``` [core] eol = lf autocrlf = input ``` ## Binary distribution Julia runs on Windows 7 and later. Both the 32-bit and 64-bit versions are supported. The 32-bit (i686) binary will run on either a 32-bit and 64-bit operating system. The 64-bit (x86_64) binary will only run on 64-bit Windows and will otherwise refuse to launch. 1. [Download](https://julialang.org/downloads) the latest version of Julia. Extract the binary to a reasonable destination folder, e.g. `C:\julia`. 2. Double-click the `julia` shortcut to launch Julia. 3. Julia's home directory is the location pointed to by the Windows environment variable `%HOME%`: this directory is for instance where the startup file `.juliarc.jl` resides. `%HOMEDRIVE%\%HOMEPATH%` is used as a fallback if `%HOME%` is not defined. ## Source distribution ### Supported build platforms - Windows 10: supported (32 and 64 bits) - **note: cross-compiling from WSL (Windows Subsystem for Linux) is currently discouraged due to WSL time stamp problems. See discussion and links in [#22074](https://github.com/JuliaLang/julia/pull/22074).** - Windows 8: supported (32 and 64 bits) - Windows 7: supported (32 and 64 bits) ### Compiling with MinGW/MSYS2 *MSYS2 provides a robust MSYS experience.* 1. Install [Python 2.x](http://www.python.org/downloads/). Do **not** install Python 3. 2. Install [CMake](http://www.cmake.org/download/). 3. Install and configure [MSYS2](https://msys2.github.io), a minimal POSIX-like environment for Windows. 1. Download and run the latest installer for the [32-bit]( http://sourceforge.net/projects/msys2/files/Base/i686/) or [64-bit]( http://sourceforge.net/projects/msys2/files/Base/x86_64/) distribution. The installer will have a name like `msys2-i686-yyyymmdd.exe` or `msys2-x86_64-yyyymmdd.exe`. 2. Double-click `msys2_shell.bat` in the installed msys directory. Initialize the MSYS2 base system using the `pacman` package manager included in MSYS2: ```sh update-core # or, if update-core is not available pacman --needed -Sy bash pacman pacman-mirrors msys2-runtime # update package database and full system upgrade pacman -Syyuu ``` 3. Exit and restart MSYS2, then install packages required to build julia: ```sh pacman -S diffutils git m4 make patch tar p7zip msys/openssh ca-certificates ``` 4. Configure your MSYS2 shell so Python is visible on the path: ```sh echo "export PATH=/usr/local/bin:/usr/bin:/opt/bin:/C/Python27" >> ~/.bashrc ``` Note, the `export` clobbers whatever `$PATH` is already defined. This is suggested to avoid path-masking. If you use MSYS2 for purposes other than building Julia, you may prefer to append rather than clobber. Note, all of the path separators are unix-style. In MSYS2, `/C/` means the root of your `C:\` drive. Replace `/C/Python27` with the location where you installed Python. 5. Configuration of MSYS2 is complete. Now `exit` the MSYS2 shell. 4. Build Julia and its dependencies from source. 1. Open a new MSYS2 shell and clone the Julia sources ```sh git clone https://github.com/JuliaLang/julia.git cd julia ``` 2. Run the following script to download the correct versions of the MinGW-w64 compilers ```sh contrib/windows/get_toolchain.sh 32 # for 32 bit Julia # or contrib/windows/get_toolchain.sh 64 # for 64 bit Julia ``` Then follow the printed instructions by running either ```sh export PATH=$PWD/usr/i686-w64-mingw32/sys-root/mingw/bin:$PATH # for 32 bit Julia # or export PATH=$PWD/usr/x86_64-w64-mingw32/sys-root/mingw/bin:$PATH # for 64 bit Julia ``` to add the downloaded MinGW-w64 compilers to your path (temporarily, only needed during the shell session when you build Julia). 3. Specify the location where you installed CMake ```sh echo 'override CMAKE=/C/path/to/CMake/bin/cmake.exe' > Make.user ``` 4. Start the build ```sh make -j 4 # Adjust the number of cores (4) to match your build environment. ``` 5. Setup Package Development Environment 1. The `Pkg` module in Base provides many convenient tools for [developing and publishing packages](https://docs.julialang.org/en/latest/manual/packages/). One of the packages added through pacman above was `openssh`, which will allow secure access to GitHub APIs. Follow GitHub's [guide]( https://help.github.com/articles/generating-ssh-keys) to setting up SSH keys to ensure your local machine can communicate with GitHub effectively. 2. In case of the issues with building packages (i.e. ICU fails to build with the following error message `error compiling xp_parse: error compiling xp_make_parser: could not load module libexpat-1: %`) run `make win-extras` and then copy everything from the `dist-extras` folder into `usr/bin`. ### Cygwin-to-MinGW cross-compiling Julia can be also compiled from source in [Cygwin](http://www.cygwin.com), using versions of the MinGW-w64 compilers available through Cygwin's package manager. 1. Download and run Cygwin setup for [32 bit](http://cygwin.com/setup-x86.exe) or [64 bit](http://cygwin.com/setup-x86_64.exe). Note, that you can compile either 32 or 64 bit Julia from either 32 or 64 bit Cygwin. 64 bit Cygwin has a slightly smaller but often more up-to-date selection of packages. Advanced: you may skip steps 2-4 by running: setup-x86_64.exe -s -q -P cmake,gcc-g++,git,make,patch,curl,m4,python,p7zip,mingw64-i686-gcc-g++,mingw64-i686-gcc-fortran,mingw64-x86_64-gcc-g++,mingw64-x86_64-gcc-fortran :: replace with a site from https://cygwin.com/mirrors.html :: or run setup manually first and select a mirror 2. Select installation location and download mirror. 3. At the '*Select Packages'* step, select the following: 1. From the *Devel* category: `cmake`, `gcc-g++`, `git`, `make`, `patch` 2. From the *Net* category: `curl` 3. From *Interpreters* (or *Python*) category: `m4`, `python` 4. From the *Archive* category: `p7zip` 5. For 32 bit Julia, and also from the *Devel* category: `mingw64-i686-gcc-g++` and `mingw64-i686-gcc-fortran` 6. For 64 bit Julia, and also from the *Devel* category: `mingw64-x86_64-gcc-g++` and `mingw64-x86_64-gcc-fortran` 4. At the *'Resolving Dependencies'* step, be sure to leave *'Select required packages (RECOMMENDED)'* enabled. 5. Allow Cygwin installation to finish, then start from the installed shortcut a *'Cygwin Terminal'*, or *'Cygwin64 Terminal'*, respectively. 6. Build Julia and its dependencies from source: 1. Get the Julia sources ```sh git clone https://github.com/JuliaLang/julia.git cd julia ``` Tip: If you get an `error: cannot fork() for fetch-pack: Resource temporarily unavailable` from git, add `alias git="env PATH=/usr/bin git"` to `~/.bashrc` and restart Cygwin. 2. Set the `XC_HOST` variable in `Make.user` to indicate MinGW-w64 cross compilation ```sh echo 'XC_HOST = i686-w64-mingw32' > Make.user # for 32 bit Julia # or echo 'XC_HOST = x86_64-w64-mingw32' > Make.user # for 64 bit Julia ``` 3. Start the build ```sh make -j 4 # Adjust the number of cores (4) to match your build environment. ``` > Protip: build both! > ```sh > make O=julia-win32 configure > make O=julia-win64 configure > echo 'XC_HOST = i686-w64-mingw32' > julia-win32/Make.user > echo 'XC_HOST = x86_64-w64-mingw32' > julia-win64/Make.user > echo 'ifeq ($(BUILDROOT),$(JULIAHOME)) > $(error "in-tree build disabled") > endif' >> Make.user > make -C julia-win32 # build for Windows x86 in julia-win32 folder > make -C julia-win64 # build for Windows x86-64 in julia-win64 folder > ``` 7. Run Julia using the Julia executables directly ```sh usr/bin/julia.exe usr/bin/julia-debug.exe ``` ### Cross-compiling from Unix If you prefer to cross-compile, the following steps should get you started. For maximum compatibility with packages that use [WinRPM.jl]( https://github.com/JuliaLang/WinRPM.jl) for binary dependencies on Windows, it is recommended that you use OpenSUSE 13.2 for cross-compiling a Windows build of Julia. If you use a different Linux distribution or OS X, install [Vagrant](http://www.vagrantup.com/downloads) and use the following `Vagrantfile`: ``` # Vagrantfile for MinGW-w64 cross-compilation of Julia $script = <