Tuesday, April 27, 2010

Build gvim 7.2 x64 and create installer for Windows 7, Vista, XP

Update with new installer and changes for building 7.3:
http://ionipti.blogspot.com/2010/08/gvim-73-64-bit-x64-windows-7-vista-xp.html

I've been getting kinda tired of not having a decent installer for gvim 7.2 on my Vista x64 system. I have figured out all of these steps, and I'm sharing them with you. You can download the actual installer from:

http://nkcorner.com/gvim72.exe (64 bit only, includes all patches up to and including 7.2.411)

This version is built exactly as I've shown below. The printing works in Windows, and so do the context menus. It also installs to the Program Files directory as it should. This is only tested on Vista x64.

Here are the steps: (I'm sure they can be somewhat simplified and I'd be happy to hear about that.)


Create a folder called building, eg c:\building

Download these files:
ftp://ftp.vim.org/pub/vim/unix/vim-7.2.tar.bz2
ftp://ftp.vim.org/pub/vim/extra/vim-7.2-extra.tar.gz
ftp://ftp.vim.org/pub/vim/extra/vim-7.2-lang.tar.gz
Unzip them using 7-zip or alternative program.
Each of these archives contain a vim72 folder, extract them all into c:\building\vim72 folder.

Download these files, and extract them to c:\building\patches
ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.001-100.gz
ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.101-200.gz
ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.201-300.gz
ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.301-400.gz

Download these files into c:\building\patches
ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.401
ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.402
ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.403
ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.404
ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.405
ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.406
ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.407
ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.408
ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.409
ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.410
ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.411

Download and install these programs:
http://cdnetworks-us-2.dl.sourceforge.net/project/gnuwin32/sed/4.2-1/sed-4.2-1-setup.exe
http://cdnetworks-us-2.dl.sourceforge.net/project/nsis/NSIS%202/2.46/nsis-2.46-setup.exe
http://hivelocity.dl.sourceforge.net/project/gnuwin32/patch/2.5.9-7/patch-2.5.9-7-setup.exe
Optionally install make, although we will be bypassing the make with a manual command due to incorrect syntax in the Makefile when running on Windows.
http://cdnetworks-us-2.dl.sourceforge.net/project/gnuwin32/make/3.81/make-3.81.exe

Add "C:\Program Files (x86)\GnuWin32\bin\" to your path variable and reopen any command prompts.

Download and extract diff.exe from:
http://hivelocity.dl.sourceforge.net/project/unxutils/unxutils/current/UnxUtils.zip
Copy diff.exe to c:\building\

Download and install Windows SDK for AMD64:
http://download.microsoft.com/download/2/E/9/2E911956-F90F-4BFB-8231-E292A7B6F287/GRMSDKX_EN_DVD.iso
If this link doesn't work, then go to
http://www.microsoft.com/downloads/details.aspx?FamilyID=71deb800-c591-4f97-a900-bea146e4fae1&displaylang=en
and download the GRMSDKX_EN_DVD.iso (which is the AMD64 version)

Download this package and copy upx.exe to c:\building\vim72\nsis
http://upx.sourceforge.net/download/upx304w.zip

Open a command prompt and run
C:\Windows\System32\cmd.exe /E:ON /V:ON /T:0E /K "C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\SetEnv.cmd" /release
Use this command prompt for building as it is now set to 64 bit release.

Install patches by changing directory to c:\building\vim72 and running these commands in this order:
patch --binary -p0 < ..\patches\7.2.001-100
patch --binary -p0 < ..\patches\7.2.101-200
patch --binary -p0 < ..\patches\7.2.201-300
patch --binary -p0 < ..\patches\7.2.301-400
patch --binary -p0 < ..\patches\7.2.401
patch --binary -p0 < ..\patches\7.2.402
patch --binary -p0 < ..\patches\7.2.403
patch --binary -p0 < ..\patches\7.2.404
patch --binary -p0 < ..\patches\7.2.405
patch --binary -p0 < ..\patches\7.2.406
patch --binary -p0 < ..\patches\7.2.407
patch --binary -p0 < ..\patches\7.2.408
patch --binary -p0 < ..\patches\7.2.409
patch --binary -p0 < ..\patches\7.2.410
patch --binary -p0 < ..\patches\7.2.411

Change directory to c:\building\vim72\src, and build using this command:
nmake -f Make_mvc.mak OLE=yes
and
nmake -f Make_mvc.mak OLE=yes GUI=yes
(First command produces vim.exe and second one produces gvim.exe)

Change directory to c:\building\vim72\runtime\doc and run
sed -e "s/[ \t]*\*[-a-zA-Z0-9.]*\*//g" -e "s/vim:tw=78://" uganda.txt | uniq >uganda.nsis.txt
This is the line that should be run from the Makefile in this directory, but Windows make.exe has trouble with it.

Change directory to c:\building\vim72\nsis and open gvmi.nsi in a text editor (preferably not notepad or wordpad...)
At line 22 change (comment out)
!define HAVE_NLS
to
#!define HAVE_NLS
(I don't have a 64-bit libintl.dll)

Replace all instances of PROGRAMFILES with PROGRAMFILES64
(Forces the default installation directory to be the Program Files directory instead of Program Files (x86).)

At line 248 change
   File /oname=vim.exe ${VIMSRC}\vimd32.exe
to
   File /oname=vim.exe ${VIMSRC}\vimw32.exe
(The check for WINNT isn't working on my Vista x64 system... so I force it)

Copy all files and directory from c:\building\vim72\runtime to c:\building\vim72

Rename these files:
c:\building\vim72\src\gvim.exe -> c:\building\vim72\src\gvim_ole.exe
c:\building\vim72\src\vim.exe -> c:\building\vim72\src\vimw32.exe
c:\building\vim72\src\install.exe -> c:\building\vim72\src\installw32.exe
c:\building\vim72\src\uninstal.exe -> c:\building\vim72\src\uninstalw32.exe

Copy and rename this file:
c:\building\vim72\src\xxd\xxd.exe -> c:\building\vim72\src\xxdw32.exe

Change directory to c:\building\vim72\nsis and run:
"c:\Program Files (x86)\NSIS\makensis.exe" gvim.nsi


Enjoy!
Nachum Kanovsky
http://nkcornerconsulting.com
FPGA & Embedded Software Expert

20 comments:

  1. thank you very much!! :)

    ReplyDelete
  2. thanks very much for this! however, i have notice some things don't work..i get erros (eg when i type mkview, i get a "cannot open blablah for writing"
    i also had the same problem with _vimrc (had to change permissions, but the other problems aren't so easily fixed...)
    any ideas?? thanks !

    ReplyDelete
  3. I'm not sure what the problem with mkview is, although I do have user access controls turned off so that may be related. If you have UAC enabled it may cause issues, I don't know.
    I also don't see a problem with _vimrc. It works fine for me.

    Can someone else confirm these issues?

    ReplyDelete
  4. i have a problem with "diff": when i compare two files i got an error on "libintl3.ddl".

    i read on some forum that this errors come with wrong installations.

    i have windows7, 64 bit.

    excuse my bad english! ;)

    ReplyDelete
  5. I see the problem. It is an issue with the installer. I will need to recompile a new diff.exe that doesn't require libintl3.dll. The solution for now is downloading and installing libintl from GnuWin32. Here's a link:

    http://iweb.dl.sourceforge.net/project/gnuwin32/libintl/0.14.4/libintl-0.14.4.exe

    ReplyDelete
  6. I have updated the installer to use diff.exe from the UnxUtils project. This removes the requirement of libintl3.dll.

    Thanks for pointing this out!

    ReplyDelete
  7. Thanks for this installer, it has saved my day!

    ReplyDelete
  8. Thanks very much for this. I'm just settling in to a Win7/64 machine and now I have my ViM fully functional!

    ReplyDelete
  9. Norton thinks there is virus in the executable.

    ReplyDelete
  10. whoa! slow down. I've not heard that anywhere else. Neither avast nor norton detect any viruses in this file. Please check again, and let me know who or what detects a virus.

    Thanx,

    ReplyDelete
  11. This is same anonymous fellow again. When file was downloaded, Norton 4.0 was suspicious because it had no info on the .exe file. When I executed it "Norton Insight" flagged something it thought was a virus and deleted the file. Maybe Norton was wrong. I only tried that once because I am just now recovered from a recent virus on my desktop. I will keep checking here. I would very much like to use Vim.

    ReplyDelete
  12. Norton/Symantec might have categorized it as a Reputation-based threat (such as WS.Reputation.1). That is, a file that only a few people have and therefore Norton doesn't think is valid. I wound up requesting a refund from Symantec after the 100th or so time their antivirus "protected" me from an uncommon piece of perfectly valid, safe software.

    ReplyDelete
  13. Sucks when that kind of stuff happens, and it's happened to all of us. Glad to hear though that vim is still good. Enjoy

    ReplyDelete
  14. Just want to say thanks. My Win7 machine is now happy.

    ReplyDelete
  15. Here is another thank from someone who bougth a new PC with windows 7 on it, without knowing that it would make a mess with all existing stuff that used to work fine on XP.
    => Thanks <=

    ReplyDelete
  16. Thank you for doing this.

    ReplyDelete
  17. Just found your post here.
    What compiler must I have installed in order to
    compile VIM? Will the free -- I think it's called
    microsoft visual express -- work? Thanks.

    ReplyDelete
  18. Glad you found the post. In the post I mention downloading the Windows SDK. That should still work fine.

    ReplyDelete
  19. Firstly, thanks for all your hard work on this and for sharing it with us.

    Someone mentioned above having an issue with the 'mkview' command.

    I too am having an issue. When I issue the 'mkview' command to save my folds I get the following error:

    E739: Cannot create directory: C:\Program Files \Vim/vimfiles/view
    E190: Cannot open "C:\Program Fiels\Vim/vimfiles/view/~=+foldtest.txt" for writing
    Press ENTER or type command to continue

    It seems that whatever veriable holds '/vimfiles/view' is still using the unix path deliminator '/' (forward slash) instead of the windows '\' (backslash).

    ReplyDelete
  20. Do you have any idea , why I get error Not connected ,
    Unknown host..... The same ftp adress user and password work in ubuntu but in windows it not working.

    ReplyDelete