-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Installing a C compiler on Windows
You can use MinGW-w64, Visual Studio, llvm-mingw, or tcc. Visual Studio takes a lot more space, but its header files are more up-to-date, so Visual Studio is preferred if you plan to use the UI library.
V uses recent Windows features like UTF-8 and color output support in console, IPv6 and native TLS support on sockets, etc. Windows 10 Fall Creators Update (1709) or later is the recommended Windows version for most complete compatibility. Windows 7, Windows 8(.1), and Windows 10 before Fall Creators Update are supported too but programs may lack some features and/or it may be hard to correctly link/redistribute recent C runtime library especially when using GNU C compiler.
Download and install MinGW-w64. I recommend installing it in C:\mingw-w64
. You can use the default installation options.
Make sure the C:\mingw-w64\bin
directory is in system's PATH, verify that by running gcc
in your terminal.
Please note that Cygwin is not supported. It's used to run *nix software that doesn't run on Windows. V has full Windows support, so there's no point in Cygwin.
Download and install Visual Studio 2019. The community edition will suffice. In the installer select Visual Studio core editor
, Desktop development with C++
, and Windows 10 SDK
.
Now you can build V by launching cmd.exe and running
cd v
make
NB: on windows, the make.bat file first tries to locate gcc from MinGW-w64, and will use it, if it finds it. If not, it will try MSVC. If you want use MSVC, when you have both MinGW-w64 AND MSVC, you can pass:
make -msvc
You can get a recent build of llvm-mingw from https://github.com/mstorsjo/llvm-mingw/releases .
The main benefit with this compiler toolchain is that the released archives are self contained. There is NO installation necessary. Just ~516MB of disk space.
-
download a .zip file from the link above.
-
unpack the downloaded .ZIP archive into a folder, say c:\llvm
-
put c:\llvm in your PATH. or
-
use
v -cc c:\llvm\bin\gcc.exe
when compiling your v source.
If you do not want to use this compiler toolchain anymore, you can simply delete the folder where you unpacked the zip (eg. C:\llvm).
tcc is a very lightweight C compiler. Its main advantages are that it takes up very little storage space (less than 10MB), and compiles C much faster than the other compilers listed here. However, it has several limitations:
- It does not optimize the resulting binaries at all. That's why it compiles faster, but the resulting binaries are slower at runtime.
- It is not as stable as GCC or Visual Studio. It can compile V and its standard library fine, but you may encounter issues if working with C interop.
For these reasons, a different and more advanced compiler is recommended.
Due to its small size, tcc is downloaded automatically if no existing C compiler is found. You can also install it manually by using .\make.bat -tcc
or git clone https://github.com/vlang/tccbin_win thirdparty/tcc
from V's root folder.