Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to compile under Windows #62

Closed
jarmo opened this issue Feb 6, 2013 · 26 comments
Closed

Unable to compile under Windows #62

jarmo opened this issue Feb 6, 2013 · 26 comments
Labels

Comments

@jarmo
Copy link

jarmo commented Feb 6, 2013

I tried to compile under windows, but failed. I used nmake to do that and getting to 81% of completion.

This is how i created the Makefile:

cmake -G "NMake Makefiles" . %HOME%/vimfiles/bundle/YouCompleteMe/cpp

This is what nmake produces:

nmake

Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

[ 81%] Built target BoostParts
[ 82%] Building CXX object ycm/CMakeFiles/ycm_core.dir/Candidate.cpp.obj
cl : Command line warning D9002 : ignoring unknown option '-isystem'
cl : Command line warning D9002 : ignoring unknown option '-isystem'
cl : Command line warning D9002 : ignoring unknown option '-isystem'
BoostParts
c1xx : fatal error C1083: Cannot open source file: 'C:\Users\Jarmo\AppData\Local\vimfiles\bundle\YouCompleteMe\cpp\BoostParts': Permission denied
include
c1xx : fatal error C1083: Cannot open source file: 'C:\ChocoPackages\Python27\include': Permission denied
include
c1xx : fatal error C1083: Cannot open source file: 'C:\Users\Jarmo\AppData\Local\vimfiles\bundle\YouCompleteMe\cpp\llvm\include': Permission denied
Candidate.cpp
c:\users\jarmo\appdata\local\vimfiles\bundle\youcompleteme\cpp\ycm\standard.h(18) : fatal error C1083: Cannot open include file: 'boost/foreach.hpp': No such file or directory
Generating Code...
NMAKE : fatal error U1077: 'C:\PROGRA~2\MICROS~1.0\VC\bin\cl.exe' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.

There doesn't seem to be any obvious reasons for getting Permission denied errors since i can cd to these directories and all the files seem to exist too.

Any ideas?

@char101
Copy link

char101 commented Feb 7, 2013

C:\Users\Jarmo\AppData\Local\vimfiles\bundle\YouCompleteMe\cpp\BoostParts is an include path in the compiler command line but somehow it's interpreted as a source file (the compier tried to open a directory as a file, that's why the permission denied error), so there is something wrong with the command line.

@Valloric
Copy link
Member

Valloric commented Feb 7, 2013

See issue #19. I haven't had time to get it working on Windows yet.

@kul
Copy link

kul commented Feb 7, 2013

Does the following error means something?
~/.vim/bundle/YouCompleteMe/cpp/BoostParts/libs/python/src/converter/builtin_converters.cpp:485:29: error: function `PyObject* boost::python::converter::do_return_to_python(char)' definition is marked dllimport

@Valloric
Copy link
Member

Valloric commented Feb 8, 2013

Nope, sorry, the message doesn't mean anything to me.

@char101
Copy link

char101 commented Feb 8, 2013

That error message is why BOOST_PYTHON_SOURCE needs to be added to the project definition.

@kul
Copy link

kul commented Feb 8, 2013

@char101 which project definition file? I am using this under cygwin
CMAKE_LEGACY_CYGWIN_WIN32=1 CC=gcc-4 CXX=g++-4 cmake -G "Unix Makefiles" -DPATH_TO_LLVM_ROOT=~/llvm/build/Release+Asserts . ~/.vim/bundle/YouCompleteMe/cpp

Also why dont you make a pull request if you are able to compile for windows?

Thanks

@char101
Copy link

char101 commented Feb 8, 2013

Add -DBOOST_PYTHON_SOURCE

By windows I mean compiling with visual studio compiler. Compiling with cygwin/mingw is more similar to compiling in linux that windows.

@jarmo
Copy link
Author

jarmo commented Feb 8, 2013

How can i specify that parameter when using nmake?

@kul
Copy link

kul commented Feb 8, 2013

@char101 ok as cmake tends to ignore manual definitions on command line i added them to CMakeLists.txt . i.e.
add_definitions(-DBOOST_PYTHON_SOURCE)
add_definitions(-DBOOST_ALL_NO_LIB)

That error is gone but i have some more
http://pastebin.com/7Sfs8Z1S

@jarmo you can do the same too i guess

EDIT:sorry about above it was due to CMAKE_LEGACY_CYGWIN_WIN32=1 flag..i was able to compile past 78% stuck in some clang isuue now (seems like my clang build was not good ). Thanks

@kul
Copy link

kul commented Feb 8, 2013

Good news is i am able to compile ycm on windows. ycm doesnt seem to link to static libclang.a but linking to cygclang.dll worked for me. After compiling i see libycm_core.dll.a and ycm_core.so ( i was expecting a dll here ) inside ycm dir. i also copied cygclang.dll to python dir. But still on opening vim ycm complains that ycm_core[so|dll] not found. I am stuck at this now.

@olajep
Copy link
Contributor

olajep commented Feb 10, 2013

@kul Did you try to rename the .so file to .dll ?

@kul
Copy link

kul commented Feb 12, 2013

Its surprising how people are able to run it on windows ...the readme never tell on which folder to copy the ycm_core.[so|dll]] to. I figured from code its looking inside python dir. Secondly the function function! s:HasYcmCore() only looks for so and pyd.

@ConnorKrammer
Copy link

When do you think Windows support will be coming? I've been beating my head against this particular brick wall for days!
I tried building using Visual Studio Express 2012 and got stuck on this error:
error LNK1104: cannot open file 'libboost_thread-vc110-mt-gd-1_52.lib'
... when trying to build ycm_core. I got to this point after manually prefixing bind and make_shared with boost:: like char101 suggested in issue #19 to fix the errors that Visual Studio was giving me.
This forum comment seems to suggest that the boost binaries are missing.

I get this whether I build with clang support or without it.

Alternatively, I also tried using the nmake method using the Developer Command Prompt for VS2012, but got stuck at the same place as Jarmo did. Again, this happened to me whether or not I built the project with clang or without it.

@saejox
Copy link

saejox commented Feb 18, 2013

I have complied with Visual Studio 2012 Express.
Here are the problems i faced:

  1. prepend boost:: to bind and make_shared in all occurrences.
  2. add these to compiler flags in both BoostParts and ycm_core /D "BOOST_PYTHON_SOURCE" /D "BOOST_ALL_NO_LIB"
    i know cmake has defines for those in there but they do no work. i didn't investigate why
  3. You need to build LLVM then build Clang. copy clang install folder to ./cpp/llvm
    LLVM and clang both use cmake and build with no issue, just takes time.
  4. ycm_core misses correct library link. Add cpp\llvm\lib\libclang.lib. Or you'll get linker errors.
  5. You may need to add /EHsc flag to compiler depending on you default settings.
  6. rename ycm_core.dll to ycm_core.pyd

Still, after a few seconds plugin gets in a infinite loop and hangs Vim.
I have no idea how debug, so i don't know which call causes the infinite loop.
Has Clang support compiled in: True
clang version 3.3 (trunk 175463)

Did anyone successfully ran YCM in windows?

@kul
Copy link

kul commented Feb 20, 2013

@Valloric Do you have modified the boost parts source code? If not, why not just ask to link against existing boost libs available for most of the platforms, it will decrease the complexity for build imo. Any thoughts?

@Valloric
Copy link
Member

@kul Nope, the Boost parts code is unmodified.

There's no package manager for Windows so it wouldn't really be easy for users to get a set of Boost binaries. Getting YCM to work on Windows is merely a matter of me finding a day of free time (which so far I haven't found) where I can get it to work there and then writing more docs. This is not my first time around the cross-platform block. :)

There's also no one universal package manager for Mac.

Bottom line, using an out-of-tree Boost would require users to perform extra steps to get YCM working (current situation with Windows notwithstanding).

@ConnorKrammer
Copy link

@Valloric Well, I did find this tool for Windows that will download Boost and compile it with Visual Studio 2010/12 (in case anyone finds that useful), but I agree about the extra steps. Also, if you didn't already need Boost for something it would be silly to download the entire Boost library set just for a Vim plugin.

@kul
Copy link

kul commented Feb 21, 2013

Ok well my point was not to download the whole library and compile it. But just getting the binaries and includes like you did for clang, and link against them. But i may be overlooking some extra effort or potential problems.

Using cmake as build system already has made build process cross platform i guess, Apart from a few thing with cmake config like renaming with .so extension intead of leaving it to cmake and adding few definitions. I was able to compile it in cygwin. Its just a matter of debugging if you ask me to get it working.

@jarmo
Copy link
Author

jarmo commented Feb 24, 2013

Can't compile even with the latest code and following instructions in the wiki. I'm seeing this error:

  ycm_core.dir\Debug\ycm_core.obj  /machine:X86 /debug
c:\ChocoPackages\Python27\python27.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x2E8 [C:\Users\Jarmo\ycm_build\ycm\ycm_core.vcxproj]

The file exists and seems to be a legal xml file. Any ideas?

@Valloric
Copy link
Member

This is the issue the wiki page talks about; you have mixed up architectures. I'm guessing python27.dll is x64 and ycm_core.obj is x86.

@jarmo
Copy link
Author

jarmo commented Feb 24, 2013

That's what i also suspected and was actually right, but i replaced 64bit Python with 32bit and i'm still getting the same error. I also have Visual Studio only for 32bits - located under Program Files (x86) directory.

This is the python information:

Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32

This is how i ran cmake and msbuild for Visual Studio 2010:

cmake -G "Visual Studio 10" -DPYTHON_INCLUDE_DIR=C:/bin/Python27/include -DPYTHON_LIBRARY=C:\Windows\SysWOW64\python27.dll . c:\Users\Jarmo\AppData\Local\vimfiles\bundle\YouCompleteMe\cpp\
msbuild /t:ycm_core /property:configuration=Release YouCompleteMe.sln

As you can see i'm pointing to the 32bit python27.dll specifically (i don't even have 64 bit version of it anymore).

@jarmo
Copy link
Author

jarmo commented Feb 24, 2013

I managed to compile it!

Right after i removed -DPYTHON_INCLUDE_DIR and -DPYTHON_LIBRARY flags it built successfully.

@stormy-henderson
Copy link

I got it to compile (without clang) using MinGW64, and added instructions to the existing wiki page. Download the 64-bit binary at http://goo.gl/SQacI if you can't get your own to compile.

@WscriChy
Copy link
Contributor

It cannot compile with .lib.

-- Found PythonLibs: D:/python/2.7/libs/python27.lib (found suitable version "2.7.3", required is "2.5")

So I think you need define to link with dll directly by adding to cmake the following:

-DPYTHON_LIBRARY=path/to/python/dll/python27.dll

You build for some reason, cannot be used with my libclang.dll, mb because of version, I have 3.3.

With the note above you build instructions work, thanks.

@saamalik
Copy link

@kul or anyone else

Did anyone figure out how to compile in Cygwin (using generator Unix Makefiles)?

I followed @stormy-henderson instructions on compiling for MinGW64:
Add the following to CMakeMakeLists.txt:

set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -include cmath")
add_definitions(-DBOOST_PYTHON_SOURCE)
add_definitions(-DBOOST_THREAD_BUILD_DLL)
$ cmake -G "Unix Makefiles" -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_LIBRARY=/usr/lib/libpython2.7 . ../cpp
$ make

Build gets 88% complete then gets the following errors:

[ 87%] Building CXX object BoostParts/CMakeFiles/BoostParts.dir/libs/thread/src/future.cpp.obj
[ 88%] Building CXX object BoostParts/CMakeFiles/BoostParts.dir/libs/thread/src/win32/thread.cpp.obj
C:/cygwin/home/saamalik/.vim/bundle/YouCompleteMe/cpp/BoostParts/libs/thread/src/win32/thread.cpp: In function ‘void boost::<unnamed>::create_current_thread_tls_key()’:
C:/cygwin/home/saamalik/.vim/bundle/YouCompleteMe/cpp/BoostParts/libs/thread/src/win32/thread.cpp:71:37: error: ‘tss_cleanup_implemented’ was not declared in this scope
C:/cygwin/home/saamalik/.vim/bundle/YouCompleteMe/cpp/BoostParts/libs/thread/src/win32/thread.cpp: In member function ‘bool boost::thread::start_thread_noexcept()’:
(continued)
In file included from C:/cygwin/home/saamalik/.vim/bundle/YouCompleteMe/cpp/BoostParts/boost/smart_ptr/shared_ptr.hpp:32:0,
                 from C:/cygwin/home/saamalik/.vim/bundle/YouCompleteMe/cpp/BoostParts/boost/shared_ptr.hpp:17,
                 from C:/cygwin/home/saamalik/.vim/bundle/YouCompleteMe/cpp/BoostParts/boost/date_time/time_clock.hpp:17,
                 from C:/cygwin/home/saamalik/.vim/bundle/YouCompleteMe/cpp/BoostParts/boost/thread/thread_time.hpp:9,
                 from C:/cygwin/home/saamalik/.vim/bundle/YouCompleteMe/cpp/BoostParts/boost/thread/lock_types.hpp:18,
                 from C:/cygwin/home/saamalik/.vim/bundle/YouCompleteMe/cpp/BoostParts/boost/thread/pthread/thread_data.hpp:12,
                 from C:/cygwin/home/saamalik/.vim/bundle/YouCompleteMe/cpp/BoostParts/boost/thread/thread.hpp:17,
                 from C:/cygwin/home/saamalik/.vim/bundle/YouCompleteMe/cpp/BoostParts/libs/thread/src/win32/thread.cpp:17:

I also tried commenting out the last three lines in ycm_core.cpp (the ones that create a dummy tss_cleanup_implemented), but it's the same results.

@saamalik
Copy link

UPDATE
Compiled using Cygwin gcc toolchain. The problem was that I was combining the downloaded Windows CMake / Python with the Cygwin Environment. Install the Cygwin packages of python and CMake.

  1. Compile VIM (might not be necessary if the cygwin Vim version is greater than 7.3.538): https://gist.github.com/saamalik/5808448
  2. Install the following packages through Cygwin setup.exe: python and CMake. Versions I used: python-2.7.3-1, cmake-2.8.9-2
  3. cd ~/.vim/bundle/YouCompleteMe
  4. mkdir build_cygwin && cd build_cygwin
  5. cmake -G "Unix Makefiles" . ../cpp # ignore the legacy cygwin error bla bla bla
  6. make ycm_core
  7. cd ~/.vim/bundle/YouCompleteMe/python/
  8. cp ~/.vim/bundle/YouCompleteMe/build_cygwin/ycm/ycm_core.pyd ycm_core.dll # notice the extension rename
  9. ln -s ycm_core.dll ycm_core.pyd # YouCompleteMe pre-checks for either a ycm_core.so (linux/mac) or ycm_core.pyd (windows) file. the cygwin python imports dll, pyc, and py extensions (NOT pyd). It would be great if Valloric adds dll as a valid ycm_core extension.

I've uploaded the compiled ycm_core.dll to: https://github.com/saamalik/dotvim/tree/master/windows_binaries.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

10 participants