This file describes how to install, or build, and use Julia on Windows.
For more general information about Julia, please see the main README or the documentation.
The built-in Windows fonts have rather poor coverage of the Unicode character
space. The free DejaVu Sans Mono
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
Additionally, rather than sticking with the default command prompt, you may want
to use a different terminal emulator program, such as
Conemu or 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,
Sublime-IJulia, or
IJulia.
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:
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
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.
-
Download the latest version of Julia. Extract the binary to a reasonable destination folder, e.g.
C:\julia
. -
Double-click the
julia
shortcut to launch Julia. -
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.
- 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.
- Windows 8: supported (32 and 64 bits)
- Windows 7: supported (32 and 64 bits)
MSYS2 provides a robust MSYS experience.
-
Install Python 2.x. Do not install Python 3.
-
Install CMake.
-
Install and configure MSYS2, a minimal POSIX-like environment for Windows.
-
Download and run the latest installer for the 32-bit or 64-bit distribution. The installer will have a name like
msys2-i686-yyyymmdd.exe
ormsys2-x86_64-yyyymmdd.exe
. -
Double-click
msys2_shell.bat
in the installed msys directory. Initialize the MSYS2 base system using thepacman
package manager included in MSYS2: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
-
Exit and restart MSYS2, then install packages required to build julia:
pacman -S diffutils git m4 make patch tar p7zip msys/openssh ca-certificates
-
Configure your MSYS2 shell so Python is visible on the path:
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 yourC:\
drive. Replace/C/Python27
with the location where you installed Python. -
Configuration of MSYS2 is complete. Now
exit
the MSYS2 shell.
-
-
Build Julia and its dependencies from source.
-
Open a new MSYS2 shell and clone the Julia sources
git clone https://github.com/JuliaLang/julia.git cd julia
-
Run the following script to download the correct versions of the MinGW-w64 compilers
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
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).
-
Specify the location where you installed CMake
echo 'override CMAKE=/C/path/to/CMake/bin/cmake.exe' > Make.user
-
Start the build
make -j 4 # Adjust the number of cores (4) to match your build environment.
-
-
Setup Package Development Environment
-
The
Pkg
module in Base provides many convenient tools for developing and publishing packages. One of the packages added through pacman above wasopenssh
, which will allow secure access to GitHub APIs. Follow GitHub's guide to setting up SSH keys to ensure your local machine can communicate with GitHub effectively. -
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: %
) runmake win-extras
and then copy everything from thedist-extras
folder intousr/bin
.
-
Julia can be also compiled from source in Cygwin, using versions of the MinGW-w64 compilers available through Cygwin's package manager.
-
Download and run Cygwin setup for 32 bit or 64 bit. 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 <url> -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 <url> with a site from https://cygwin.com/mirrors.html :: or run setup manually first and select a mirror
-
Select installation location and download mirror.
-
At the 'Select Packages' step, select the following:
- From the Devel category:
cmake
,gcc-g++
,git
,make
,patch
- From the Net category:
curl
- From Interpreters (or Python) category:
m4
,python
- From the Archive category:
p7zip
- For 32 bit Julia, and also from the Devel category:
mingw64-i686-gcc-g++
andmingw64-i686-gcc-fortran
- For 64 bit Julia, and also from the Devel category:
mingw64-x86_64-gcc-g++
andmingw64-x86_64-gcc-fortran
- From the Devel category:
-
At the 'Resolving Dependencies' step, be sure to leave 'Select required packages (RECOMMENDED)' enabled.
-
Allow Cygwin installation to finish, then start from the installed shortcut a 'Cygwin Terminal', or 'Cygwin64 Terminal', respectively.
-
Build Julia and its dependencies from source:
-
Get the Julia sources
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, addalias git="env PATH=/usr/bin git"
to~/.bashrc
and restart Cygwin. -
Set the
XC_HOST
variable inMake.user
to indicate MinGW-w64 cross compilationecho '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
-
Start the build
make -j 4 # Adjust the number of cores (4) to match your build environment.
Protip: build both!
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
-
-
Run Julia using the Julia executables directly
usr/bin/julia.exe usr/bin/julia-debug.exe
If you prefer to cross-compile, the following steps should get you started.
For maximum compatibility with packages that use 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 and use the following Vagrantfile
:
# Vagrantfile for MinGW-w64 cross-compilation of Julia
$script = <<SCRIPT
# Change the following to i686-w64-mingw32 for 32 bit Julia:
export XC_HOST=x86_64-w64-mingw32
# Change the following to 32 for 32 bit Julia:
export BITS=64
zypper addrepo http://download.opensuse.org/repositories/windows:mingw:win$BITS/openSUSE_13.2/windows:mingw:win$BITS.repo
zypper --gpg-auto-import-keys refresh
zypper -n install --no-recommends git make cmake tar wine which curl \
python python-xml patch gcc-c++ m4 p7zip.i586 libxml2-tools winbind
zypper -n install mingw$BITS-cross-gcc-c++ mingw$BITS-cross-gcc-fortran \
mingw$BITS-libstdc++6 mingw$BITS-libgfortran3 mingw$BITS-libssp0
# opensuse packages the mingw runtime dlls under sys-root/mingw/bin, not /usr/lib64/gcc
cp /usr/$XC_HOST/sys-root/mingw/bin/*.dll /usr/lib*/gcc/$XC_HOST/*/
git clone git://github.com/JuliaLang/julia.git julia
cd julia
make -j4 win-extras julia-ui-release
export WINEDEBUG=-all # suppress wine fixme's
# this last step may need to be run interactively
make -j4 binary-dist
SCRIPT
Vagrant.configure("2") do |config|
config.vm.box = "bento/opensuse-13.2"
config.vm.provider :virtualbox do |vb|
# Use VBoxManage to customize the VM. For example to change memory:
vb.memory = 2048
end
config.vm.provision :shell, :inline => $script
end
If you don't care that the build is potentially incompatible with the WinRPM ecosystem (or happen to be on opensuse), use the following steps to cross- compile julia:
First, you will need to ensure your system has the required dependencies. We need wine (>=1.7.5), a system compiler, and some downloaders.
On Ubuntu (on other linux systems, the dependency names are likely to be similar):
apt-get install wine subversion cvs gcc wget p7zip-full winbind
On Mac: Install XCode, XCode command line tools, X11 (now XQuartz), and MacPorts
or Homebrew. Then run port install wine wget
,
or brew install wine wget
, as appropriate.
On Both: Unfortunately, the version of gcc installed by Ubuntu targets pthreads. On Mac, the situation is similar: the version in MacPorts is very old and Homebrew does not have it. So first we need to get a cross-compile version of gcc. Most binary packages appear to not include gfortran, so we will need to compile it from source. This is typically quite a bit of work, so we will use this script to make it easy.
-
svn checkout svn://svn.code.sf.net/p/mingw-w64-dgn/code/trunk mingw-w64-dgn
-
cd mingw-w64-dgn
-
edit
rebuild_cross.sh
and make the following two changes:- uncomment
export MAKE_OPT="-j 2"
, if appropriate for your machine - add
fortran
to the end of--enable-languages=c,c++,objc,obj-c++
- uncomment
-
bash update_source.sh
-
bash rebuild_cross.sh
-
mv cross ~/cross-w64
-
export PATH=$HOME/cross-w64/bin:$PATH
Note, that it is important that you remember to always
export PATH=...
before usingmake
in the following steps! You can put this line in your~/.profile
to make it easy.
Then we can essentially just repeat these steps for the 32-bit compiler, reusing some of the work:
-
cd ..
-
cp -a mingw-w64-dgn mingw-w32-dgn
-
cd mingw-w32-dgn
-
rm -r cross build
-
bash rebuild_cross.sh 32r
-
mv cross ~/cross-w32
-
export PATH=$HOME/cross-w32/bin:$PATH
Note, that it is important that you remember to always
export PATH=...
before usingmake
in the following steps! You can put this line in your~/.profile
to make it easy.
Note: for systems that support rpm-based package managers, the necessary dependencies can be downloaded from the OpenSUSE build service (see the Vagrant script above).
@vtjnash occassionally upload his builds, so you can also download those to save build time:
- x86_64-w64-mingw64 gcc-5.2.0 MacOS-10.10 (105 MB)
- i686-w64-mingw64 gcc-5.2.0 MacOS-10.10 (89 MB)
- *-w64-mingw64 gcc-4.9.2 Ubuntu-15.04 (168 MB)
Then run the build:
git clone https://github.com/JuliaLang/julia.git julia-win32
echo override XC_HOST = i686-w64-mingw32 >> Make.user
make
make win-extras
(Necessary before runningmake binary-dist
)make binary-dist
- move the
julia-*.exe
installer to the target machine
If you are building for 64-bit windows, the steps are essentially the same.
Just replace i686
in XC_HOST
with x86_64
. (note: on Mac, wine only runs
in 32-bit mode).
The most effective way to debug a cross-compiled version of julia on the cross-
compilation host is to install a windows version of gdb and run it under wine as
usual. The pre-built packages available as part of the MSYS2 project are known to work.
Apart from the GDB package you may also need the python and termcap packages.
Finally, GDB's prompt may not work when launch from the command line. This can
be worked around by prepending wineconsole
to the regular GDB invocation.
Vagrant can also be used with a Windows
guest VM via the Vagrantfile
in contrib/windows,
just run vagrant up
from that folder. To build with Cygwin instead of MSYS2,
replace config.vm.provision :shell, privileged: false, :inline => $script_msys2
(near the end of the file) with config.vm.provision :shell, privileged: false, :inline => $script_cygwin
.
Compiling using one of the options above creates a basic Julia build, but not some
extra components that are included if you run the full Julia binary installer.
If you need these components, the easiest way to get them is to build the installer
yourself using make win-extras
followed by make binary-dist
, and then
running the resulting installer.
- Run gdb under the windows console (cmd) instead. gdb may not function properly under mintty with non-
cygwin applications. You can use
cmd /c start
to start the windows console from mintty if necessary.
- Use the PID from the windows task manager or
WINPID
from theps
command instead of the PID from unix style command line tools (e.g.pgrep
). You may need to add the PID column if it is not shown by default in the windows task manager.
- When attaching to the julia process, GDB may not be attaching to the right
thread. Use
info threads
command to show all the threads andthread <threadno>
to switch threads. - Be sure to use a 32 bit version of GDB to debug a 32 bit build of Julia, or a 64 bit version of GDB to debug a 64 bit build of Julia.
-
Disable the Windows Superfetch and Program Compatibility Assistant services, as they are known to have spurious interactions with MinGW/Cygwin.
As mentioned in the link above: excessive memory use by
svchost
specifically may be investigated in the Task Manager by clicking on the high-memorysvchost.exe
process and selectingGo to Services
. Disable child services one-by-one until a culprit is found. -
Beware of BLODA. The vmmap tool is indispensable for identifying such software conflicts. Use vmmap to inspect the list of loaded DLLs for bash, mintty, or another persistent process used to drive the build. Essentially any DLL outside of the Windows System directory is potential BLODA.