Windows
This document describes how to install or build and use Julia on Windows.
For more general information about Julia, see https://github.com/JuliaLang/julia/blob/master/README.md [main README file] or https://docs.julialang.org [documentation].
General information for Windows
We strongly recommend running Julia using a modern terminal application, in particular Windows Terminal, which can be installed from https://aka.ms/terminal [Microsoft Store].
Line endings
In Julia, files are used exclusively in binary mode. Unlike many other Windows programs, when writing \n
to a file, it will contain \n
, and not any other bit pattern. This corresponds to the behavior in other operating systems. If you have installed Git for Windows, it is assumed that the Git system is configured to use the same convention, however, this is an optional requirement.:
git config --global core.eol lf
git config --global core.autocrlf input
You can also add or change the following lines in the %USERPROFILE%\.gitconfig
file:
[core] eol = lf autocrlf = input
Distribution of binary files
For installation notes regarding the distribution of binary files in Windows, see the instructions at https://julialang.org/downloads/platform/#windows .
Source code distribution
Cross-compilation from Cygwin to MinGW
The recommended way to compile Julia from source code in Windows is to cross-compile from https://www.cygwin.com [Cygwin] using MinGW-w64 compiler versions available through the Cygwin Package Manager.
-
Download and run the Cygwin installer for https://cygwin.com/setup-x86.exe [32-bit] or https://cygwin.com/setup-x86_64.exe [64-bit systems]. Please note: You can compile a 32-bit or 64-bit version of Julia using either a 32-bit or 64-bit version of Cygwin. In the 64-bit version of Cygwin, the set of packages is slightly smaller, but they are usually more up-to-date.
Additionally: Steps 2—4 can be skipped by running the following command:
setup-x86_64.exe -s <url> -q -P cmake,gcc-g++,git,make,patch,curl,m4,python3,p7zip,mingw64-i686-gcc-g++,mingw64-i686-gcc-fortran,mingw64-x86_64-gcc-g++,mingw64-x86_64-gcc-fortran
replace the
<url>
with the site address with https://cygwin.com/mirrors.html alternatively, run the installation manually first, and then select a mirror. -
Select the installation location and the mirror from where the download will be performed.
-
In the Select Packages step, select the following values.
-
In the evel (Development) category: 'cmake',
gcc-g++
,git
,make', `patch
-
In the Net (Network) category: `curl'
-
In the Interpreters (Interpreters) (or Python) category:
m4
, `python3' -
In the Archive (Archive) category: 'p7zip'
-
For the 32-bit version of Julia, as well as in the Devel (Development) category:
mingw64-i686-gcc-g++
and `mingw64-i686-gcc-fortran' -
For the 64-bit version of Julia, as well as in the evel (Development) category:
mingw64-x86_64-gcc-g++
and `mingw64-x86_64-gcc-fortran'.
-
-
Wait for Cygwin installation to complete, and then launch the environment using the installed shortcut Cygwin Terminal (Cygwin Terminal) or Cygwin64 Terminal (Cygwin64 Terminal), respectively.
-
Build Julia and dependencies from the source code.
-
Get the Julia source code
git clone https://github.com/JuliaLang/julia.git cd julia
The Council. If Git returns the error
error: cannot fork() for fetch-pack: Resource temporarily unavailable
, addalias git="env PATH=/usr/bin git"
to~/.bashrc
and restart Cygwin. -
Set the
XC_HOST
variable in theMake.user
file to configure MinGW-w64 cross-compilationecho 'XC*HOST = i686-w64-mingw32' > Make.user # для 32-разрядной версии Julia # или echo 'XC*HOST = x86_64-w64-mingw32' > Make.user # для 64-разрядной версии Julia
-
Run the build
make -j 4 # Настройте количество потоков (4) в соответствии со средой сборки. make -j 4 debug # В результате создается файл julia-debug.exe
-
-
Run Julia using Julia executables directly
usr/bin/julia.exe usr/bin/julia-debug.exe
!!! note "Pro tip: 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 # сборка для Windows x86 в папке julia-win32
make -C julia-win64 # сборка для Windows x86-64 в папке julia-win64
link:@id Compiling-with-MinGW/MSYS2[Compilation using MinGW/MSYS2]
https://www.msys2.org /[MSYS2] is a software distribution and build environment for Windows.
Note. MSYS2 requires a 64-bit version of Windows 7 or later.
-
Install and configure MSYS2.
-
Download and run the latest version of the installer for https://github.com/msys2/msys2-installer/releases/latest [64-bit] distribution. The installer will have a name like `msys2-x86_64-yyyymmdd.exe `.
-
Open the MSYS2 shell. Update the package database and base packages:
pacman -Syu
-
Exit and restart MSYS2. Update the rest of the base packages:
pacman -Syu
-
-
Then install the tools needed to build Julia.:
pacman -S cmake diffutils git m4 make patch tar p7zip curl python
For the 64-bit version of Julia, install version x86_64:
pacman -S mingw-w64-x86_64-gcc
For the 32-bit version of Julia, install the i686 version.:
pacman -S mingw-w64-i686-gcc
-
MSYS2 setup is complete. Now close (
exit
) the MSYS2. 2 shell. Build Julia and the dependencies with the pre-assembled dependencies. -
Open a new one https://www.msys2.org/docs/environments/#overview [the MINGW64/MINGW32 shell]. Currently, you cannot use mingw32 and mingw64 at the same time, so if you want to build versions x86_64 and i686, you will need to do this in each environment separately.
-
Clone the Julia source code:
git clone https://github.com/JuliaLang/julia.git cd julia
-
Run the build
make -j$(nproc)
!!! note "Pro tip: build in dir"
make O=julia-mingw-w64 configure echo 'ifeq ($(BUILDROOT),$(JULIAHOME)) $(error "in-tree build disabled") endif' >> Make.user make -C julia-mingw-w64
-
link:@id Cross-compiling-from-Unix-(Linux/Mac/WSL)[Cross-compilation from Unix (Linux, Mac, WSL)]
You can also use MinGW-w64 cross-compilers to build the Julia Windows version from Linux, Mac, or the Windows Subsystem for Linux (WSL).
First, you need to make sure that the necessary dependencies are present in your system. You will need wine (version 1.7.5 or later), a system compiler, and a number of loaders. Note. Cygwin installation may block the execution of this method when using WSL.
In Ubuntu (in other Linux systems, dependency names are likely to be similar):
apt-get install wine-stable gcc wget p7zip-full winbind mingw-w64 gfortran-mingw-w64
dpkg –add-architecture i386 && apt-get update && apt-get install wine32
# switch all of the following to their "-posix" variants (interactively):
for pkg in i686-w64-mingw32-g++ i686-w64-mingw32-gcc i686-w64-mingw32-gfortran x86_64-w64-mingw32-g++ x86_64-w64-mingw32-gcc x86_64-w64-mingw32-gfortran; do
sudo update-alternatives --config $pkg
done
On Mac: install XCode, XCode command line programs, X11 (now https://www.xquartz.org /[XQuartz]) and https://www.macports.org/install.php [MacPorts] or https://brew.sh /[Homebrew]. Then run the command port install wine wget mingw-w64
or brew install wine wget mingw-w64
, depending on the situation.
Next, perform the assembly:
-
git clone https://github.com/JuliaLang/julia.git julia-win32
-
cd julia-win32
-
echo override XC_HOST = i686-w64-mingw32 >> Make.user
-
make
-
`make win-extras' (required before executing `make binary-dist')
-
make binary-dist
and thenmake exe
to create the Windows installer. -
Transfer the installer
julia-*.exe
to the target computer.
When building for 64-bit versions of Windows, the steps will be basically the same. Just replace the i686
in XC_HOST
with `x86_64'. (Note. On Mac, wine runs only in 32-bit mode.)
Debugging a cross-compiled build in wine
The most effective way to debug a cross-compiled version of Julia on a cross-compilation host is to install the Windows version of GDB and run it in the wine environment in the usual way. Pre-assembled packages available https://packages.msys2.org /[as part of the MSYS2 project], should work. In addition to the GDB package, you may also need python and termcap packages. Finally, the GDB command line may not work when running from the command line. To get around this problem, add `wineconsole' before the regular GDB call.
After compilation
As a result of compilation with one of the above parameters, a basic Julia build is created without additional components that are enabled when running the full Julia binary installer. If you need these components, the easiest way to get them is to build the installer yourself by running the command make win-extras
, followed by make binary-dist
and `make exe'. Next, run the final installer.
Debugging a Windows build
GDB freezes in Cygwin mintty
-
Run GDB in the Windows Console (cmd). GDB https://www.cygwin.com/ml/cygwin/2009-02/msg00531.html [may not work correctly] in mintty with applications not designed for the Cygwin environment. If necessary, you can start the Windows console from mintty using the command `cmd /c start'.
GDB is not connected to the desired process
-
Use the PID from the Windows Task Manager or the
WINPID
from the output of theps' command instead of the PID from Unix-style command-line programs (for example, `pgrep
). You may need to add a PID column if it is not displayed by default in the Windows Task Manager.
GDB outputs an incorrect backtrace
-
When connecting to a Julia process, GDB may not connect to the corresponding thread. Use the 'info threads` command to output all threads and the
thread <threadno>
command to switch threads. -
Be sure to use the 32-bit version of GDB to debug the 32-bit Julia build and the 64-bit version of GDB to debug the 64-bit Julia build.
The build process is slow, consumes a lot of memory, or freezes the computer.
-
Disable Windows Services https://en.wikipedia.org/wiki/Windows_Vista_I/O_technologies#SuperFetch [Superfetch] and Program Compatibility Assistant, as it is known that they carry out https://cygwin.com/ml/cygwin/2011-12/msg00058.html [fictitious interactions] with MinGW/Cygwin.
As indicated in the link above, the reason for excessive memory consumption by the
svchost
process can be found by clicking on the process in the task managersvchost.exe ` and by selecting the `Go to Services
option. Turn off the child services one at a time until you find the culprit. -
Beware of apps from https://cygwin.com/faq/faq.html#faq.using .bloda[of the BLODA list]. To identify conflicts related to such software, you can’t do without a tool. https://technet.microsoft.com/en-us/sysinternals/dd535533 .aspx[vmmap]. Using vmmap, check the list of downloaded DLL libraries to find bash, mintty, or another persistent process used for the build. Practically any DLL library not from the Windows system directory may be the cause of a BLOD conflict.