Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Building Neovim with MSVC 2015

Check the pull request for the changes and the main issue for discussion. If you run into trouble check the Known Errors section at the end, or drop me a comment.

Requirements

  • MSVC 2015, cl should report > 19.*
  • Python 2 (required by libuv to get gyp) - python 3 will not work, see the issue
  • Git (required by libuv to get gyp)
  • libintl
  • You might need the Windows 10 SDK to be installed (unverified, please drop me a comment in #810, specially if you are in Windows8 or lower.)

Assuming you have all of the above, just get my work branch

git clone https://github.com/equalsraf/neovim.git
cd neovim
git checkout tb-win32-any

Building Neovim dependencies

Before we can build Neovim we need to build some static dependencies, from the Neovim src folder do the following

mkdir .deps
cd .deps
cmake ..\third-party\
cmake --build . --config Release

If CMake complains that it cannot find Python, include the path to python.exe like this

-DPYTHON_EXECUTABLE=c:\Python27\python.exe

Build Neovim

Go back to the main Neovim source directory and do the following

mkdir build
cd build
cmake ..
cmake --build . --config Release

nvim.exe should be in the bin/ folder. The windows version does not have a Terminal UI right now so you will need to use one of the available Neovim remote UIs (Atom, neovim-qt, python-client, ??).

Running the tests

The unit tests are not working, but the functional tests are. Some will fail for sure. After calling the initial cmake you can

cmake --build . --target functionaltest --config Release

Most likely this WILL GET STUCK. Check TEST_FILE to call a specific test.

Knowm Errors

Libuv/gyp error

Sometimes when building libuv, gyp will fail to use the correct version of visual studio and attempt to use another instead, e.g.

    C:\Program Files
    (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Platform.targets(64,5):
    error MSB8020: The build tools for Visual Studio 2010 (Platform
    Toolset = 'v100') cannot be found. To build using the v100 build
    tools, please ins tall Visual Studio 2010 build tools.
    Alternatively, you may upgrade to the current Visual Studio tools by
    selecting the Project menu or right-click the solution, and then
    selecting "Upgrade Solution...". [E:\repos\neovim\.deps\build\src\l
    ibuv\uv_dtrace_provider.vcxproj]
    NMAKE : fatal error U1077: 'call' : return code '0x1' 

You can force the correct version with an environment variable

set GYP_MSVS_VERSION=2015

MSVC Runtimes

e.g. if you see errors like this you are using multiple runtimes across different libraries

 error LNK2005: ___scrt_acquire_startup_lock already defined in LIBCMTD.lib

See http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx bottom line is you must NOT mix runtimes, i.e. all components MUST be built using the same runtime - right now I am using /MT or /MTd for Neovim (usually /MTd since builds default to Debug). Also some tricks to try and debug issues here

  • Also /VERBOSE:LIB may be helpful
  • Do not mix static (/MT) from different MSVC compilers, the result will not be pretty (e.g. undefined reference to snprintf)

Another variation of the same issue is

Debug Assertion Failed (_osfile(fh) & FOPEN)

This one trickier because it is a runtime exception, rather than a compile time error.

CMake build fails and the output is useless

When using the VS generator raise verbosity like this cmake --build . -- /verbosity:detailed.

Another alternative is to use cmake with the nmake generator, add -G "NMake Makefiles" to the initial cmake commands, but requires the cl/nmake commands to be in your PATH (e.g. call vcvarsall32.bat). Use nmake VERBOSE=1 to build.

@zolem

This comment has been minimized.

Show comment Hide comment
@zolem

zolem Jun 23, 2015

I get the following error when running the last command below. Any ideas? I am using babun.

mkdir .deps
cd .deps
cmake ..\third-party\
cmake --build .
[ 10%] Performing install step for 'jemalloc'
install -m 644 include/jemalloc/jemalloc.h /home/Rudy/projects/neovim/.deps/usr/include/jemalloc
src/jemalloc.c:1:0: warning: -fPIC ignored for target (all code is position independent)
 #define JEMALLOC_C_
 ^
In file included from src/jemalloc.c:2:0:
include/jemalloc/internal/jemalloc_internal.h:17:27: fatal error: sys/syscall.h: No such file or directory
 #  include <sys/syscall.h>
                           ^
compilation terminated.
Makefile:236: recipe for target 'src/jemalloc.pic.o' failed
make[3]: *** [src/jemalloc.pic.o] Error 1
CMakeFiles/jemalloc.dir/build.make:65: recipe for target 'build/src/jemalloc-stamp/jemalloc-install' failed
make[2]: *** [build/src/jemalloc-stamp/jemalloc-install] Error 2
CMakeFiles/Makefile2:134: recipe for target 'CMakeFiles/jemalloc.dir/all' failed
make[1]: *** [CMakeFiles/jemalloc.dir/all] Error 2
Makefile:76: recipe for target 'all' failed
make: *** [all] Error 2

zolem commented Jun 23, 2015

I get the following error when running the last command below. Any ideas? I am using babun.

mkdir .deps
cd .deps
cmake ..\third-party\
cmake --build .
[ 10%] Performing install step for 'jemalloc'
install -m 644 include/jemalloc/jemalloc.h /home/Rudy/projects/neovim/.deps/usr/include/jemalloc
src/jemalloc.c:1:0: warning: -fPIC ignored for target (all code is position independent)
 #define JEMALLOC_C_
 ^
In file included from src/jemalloc.c:2:0:
include/jemalloc/internal/jemalloc_internal.h:17:27: fatal error: sys/syscall.h: No such file or directory
 #  include <sys/syscall.h>
                           ^
compilation terminated.
Makefile:236: recipe for target 'src/jemalloc.pic.o' failed
make[3]: *** [src/jemalloc.pic.o] Error 1
CMakeFiles/jemalloc.dir/build.make:65: recipe for target 'build/src/jemalloc-stamp/jemalloc-install' failed
make[2]: *** [build/src/jemalloc-stamp/jemalloc-install] Error 2
CMakeFiles/Makefile2:134: recipe for target 'CMakeFiles/jemalloc.dir/all' failed
make[1]: *** [CMakeFiles/jemalloc.dir/all] Error 2
Makefile:76: recipe for target 'all' failed
make: *** [all] Error 2
@fntlnz

This comment has been minimized.

Show comment Hide comment
@fntlnz

fntlnz Aug 14, 2015

Thank you for this gist!
Just a thing, the package lua-messapack does not exists, I think it should be lua-messagepack

fntlnz commented Aug 14, 2015

Thank you for this gist!
Just a thing, the package lua-messapack does not exists, I think it should be lua-messagepack

@equalsraf

This comment has been minimized.

Show comment Hide comment
@equalsraf

equalsraf Aug 29, 2015

FYI sadly gist does not send notifications when you guys comment, so I completely missed these two comments.

Owner

equalsraf commented Aug 29, 2015

FYI sadly gist does not send notifications when you guys comment, so I completely missed these two comments.

@tallpauley

This comment has been minimized.

Show comment Hide comment
@tallpauley

tallpauley Mar 11, 2016

For those who are just looking for a working binary, grab an installer exe from the latest passing build:
https://ci.appveyor.com/project/equalsraf/neovim/history

For those who are just looking for a working binary, grab an installer exe from the latest passing build:
https://ci.appveyor.com/project/equalsraf/neovim/history

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment