MSYS2 + mingw-w64 + Git + gVim environment configuration

Source: Internet
Author: User
Tags git clone git mergetool
First. Installation of MSYS2


The advantage of MSYS2 first is that you can set the $HOME as/home/name/, and then install other *nix tools when the configuration files will be placed in the MSYS2/home/name, convenient management.



1. Download and install to http://sourceforge.net/projects/msys2/.



Install location set to D:/develop/msys64



Add environment variable Home is D:\develop\msys64\home\name, this variable is very useful, the following configuration to be used more than once.



2. Run Msys2_shell.bat


Pacman-sy


Update Local package data



3. Upgrade the core package


Pacman-s--needed filesystem msys2-runtime bash libreadline libiconv libarchive libgpgme libcurl Pacman ncurses Libintl


Then you need to close all MSYS2 shells and then run Autorebase.bat



4. Upgrade other Packages


Pacman-su
Operating Environment Description:


You can see that MSYS2 has three execution scripts, namely Msys2_shell.bat, Mingw32_shell.bat, and Mingw64_shell.bat, where you can see that there is only one line of difference, that is, set the Msystem variable. This variable is used in/etc/profile:


if [ -n "$MSYSTEM" ]
then
  case "$MSYSTEM" in
    MINGW32)
      PATH="/mingw32/bin:${MSYS2_PATH}:${PATH}"
      PKG_CONFIG_PATH="/mingw32/lib/pkgconfig"
      MANPATH="/mingw32/share/man:${MANPATH}"
      TERMINFO=/mingw32/share/terminfo:${TERMINFO}
    ;;
    MINGW64)
      PATH="/mingw64/bin:${MSYS2_PATH}:${PATH}"
      PKG_CONFIG_PATH="/mingw64/lib/pkgconfig"
      MANPATH="/mingw64/share/man:${MANPATH}"
      TERMINFO=/mingw64/share/terminfo:${TERMINFO}
    ;;
    MSYS)
      PATH="${MSYS2_PATH}:/opt/bin:${PATH}"
      PKG_CONFIG_PATH="/usr/lib/pkgconfig:/lib/pkgconfig"
      TERMINFO=/usr/share/terminfo
    ;;
    *)
      PATH="${MSYS2_PATH}:${PATH}"
    ;;
  esac
else
  PATH="${MSYS2_PATH}:${PATH}"
fi


Visible, the difference of three. BAT is the setting of PATH, Mingw32_shell.bat priority to use the tools under MSYS64/MINGW32, Mingw64_shell.bat priority to use the tools under Msys64/mingw64, and msys2_s Hell.bat two are not used, only use their own msys tools. The advantage of this is that when you need to compile 32bit Target projects, use the mingw32_shell.bat,64 bit to use Mingw64_shell.bat, and each set of tools does not interfere with each other. 


Second. installation of GCC



Any shell.bat can do it.



1. View the available installation packages


PACMAN-SL | grep gcc


You can see the following three


Mingw32 mingw-w64-i686-gcc 4.9.1-3
mingw64 mingw-64-x86_64-gcc 4.9.1-3
msys gcc 4.8.2-2


Corresponds to the Msys three. BAT environment respectively. Here first, the other similar.



2. Installation


Pacman-s MINGW-W64-I686-GCC


MSYS2 will automatically wrap the package under Msys64/mingw32, and from the previous analysis it is known that only Mingw32_shell.bat will use the program in this directory.



3. Run



Open Mingw32_shell.bat to try:


GCC--version
gcc.exe (Rev3, Built by MSYS2 project) 4.9.1
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; The source for copying conditions.  There is NO
warranty, not even to merchantability or FITNESS for A particular.
Third, install Git


1. Download Git for Windows. The installation process selects Git cheetah plug-in and Run git from Windows Command Prompt so that the Vim Vundle plug-in can call git.



Because the home environment variable has been set when MSYS2 is installed, Git automatically places the profile in the home and will be able to share a set of configurations for future use in MSYS2.



To install MSYS2 git:


Pacman-s git


2. Set Autocrlf as input.


git config--global core.autocrlf input


Because of setting the home environment variable, you can make Gvim and MSYS2 vim share a set of configuration files: ~/.VIMRC, Plug-ins can also be unified under ~/.vim/. When using Vundle, the code that GIT clones is a UNIX newline character that prevents MSYS2 vim from reading the Vundle plug-in file.



3. KDIFF3 used as a diff and merge tool is very convenient, but also installed it. Configure Git after installing:


git config--global merge.tool kdiff3
git config--global mergetool.kdiff3.path "C:/Program Files/kdiff3/kdiff3.exe "


A space in the middle can also be handled correctly. Try git mergetool and git difftool to see if the configuration is correct. To avoid prompting for confirmation every time you use Git Difftool, the following two lines can also be set:


git config--global mergetool.prompt false
git config--global difftool.prompt false
Fourth. Install GVim and configure Vundle for plug-in management


1. Install GVim to D:\develop\Vim, component Select full



2. Because the home environment variable is set, the Gvim configuration can be unified in the home directory



Delete all the folders under Vim/vimfiles and create a new bundle folder under ~/.vim



3. Refer to Vundle.vim's tutorial set up Git's Curl script:



Https://github.com/gmarik/Vundle.vim/wiki/Vundle-for-Windows



4. Gmarik/vundle.vim git clone to ~/.vim/bundle:


CD ~/.vim/bundle
git clone https://github.com/gmarik/Vundle.vim.git


5. Continue to refer to the Vundle.vim tutorial to modify the ~/.VIMRC file to add content to the beginning. Although using Gvim in a Windows environment, the following settings are easier to configure by LUnix because the home environment variable is set:


Set Rtp+=~/.vim/bundle/vundle.vim call
Vundle#begin ()


The plugin will be automatically installed in the $HOME/.vim/bundle directory at a later time.



6. Modify. VIMRC Add the plug-in package to install and then run in GVim


:P Lugininstall


7. You can now use: H vundle to see Vundle's help. 

Fifth. Other configurations



1. Add the GVim directory to the PATH environment variable and set Git to use GVim as the default editor:


git config--global core.editor gvim


2. To map the common working directory to MSYS2, you can use the Mount command (join. Bash_profile):


mount-fo binary,noacl,posix=0,user D:/docs ~/docs 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.