RosettaCommons / binder

Binder, tool for automatic generation of Python bindings
MIT License
319 stars 67 forks source link

Prebuilt binaries for Windows? Possible? #37

Closed aalavandhaann closed 6 years ago

aalavandhaann commented 6 years ago

Is it possible to have pre-built binaries of binder for Windows 7? I am not sure if it is too much to ask for. I found it was a swift breeze building binder on an unix system. But with Windows, Visual Studio, ATL libraries everything is a royal pain everywhere in the body.

Regards,

0K

lyskov commented 6 years ago

Our project does not use Windows so we never tested Binder on Windows (and I do not have Windows machine in my possession) so i do not have such binaries.

aalavandhaann commented 6 years ago

@lyskov ,

Apologies if I pissed you off for it was never my intention. I will try compiling binder on windows. This is necessary to generate the binding files for windows. As of now my python library using the bindings of Binder is compiled well on Linux but not on Windows. Thought I should compile binder for Windows to generate the windows bindings of my c/c++ source code. While I am not sure if it is worth the time to build binder on windows if it cannot generate bindings on Windows. Hmmm, this is such a lovely tool, something needs to be done about this. I am quite clueless about where to begin for such an effort. Not so experienced with Windows.

Regards,

0K

lyskov commented 6 years ago

No worries! I was just trying to convey that there is no Windows binaries laying around here.

Have you already checked official LLVM guild for building on WIndows? ie https://llvm.org/docs/GettingStartedVS.html - i would start there since Binder is just add-on to LLVM framework.

aalavandhaann commented 6 years ago

@lyskov Thanks for this pointer. I was examining the way binder tries to build the binary on unix. I see that putting the source files inside clang/tools/extra should do the job. Let me try it and see if a binary could be generated.

Regards,

0K

vmullig commented 6 years ago

Windows is still a huge chunk of the operating system pie -- particularly for laptops and desktops, the computers still typically used for actual work. It also tends to be the operating system of choice for biologists with less computational background, a group of people for whom it would be in our best interests to make Rosetta more attractive (since there are Windows-compatible alternatives out there). Plus, Rosetta@home and Foldit have to run on a lot of Windows devices, and putting out the new Windows builds always means solving a lot of Windows-specific Rosetta issues that have crept in since the last release. This has come up before a few times, but it would be good if we could invest some time figuring out how to support Windows better.

https://en.wikipedia.org/wiki/Usage_share_of_operating_systems

roccomoretti commented 6 years ago

@vmullig Note this is comment chain is for the public binder repository, rather than for Rosetta proper.

vmullig commented 6 years ago

Ah sorry -- I mean that more as a Rosetta issue.

aalavandhaann commented 6 years ago

@lyskov ,

I managed to build Binder on Windows 7 using Cygwin and GCC 6.4.0. The link to those binaries are here .

I am not sure how much useful this will be for others but still something from my side to support your wonderful work. I will be happy to share the steps on building binder on windows. But still there are issues when I am trying to generate binding files using the windows binary. The issues are pretty basic. Like the generator is not able to find basic headers like vector, iomanip, map etc., I will try to fix them ASAP and keep you posted. Once we have a successful generation of a project using binder for Windows I hope the tool spreads its light to more neighborhood.

Regards,

0K

aalavandhaann commented 6 years ago

@lyskov.

Okay looks like clang++ built from the source is not able to pick up the standard header files under the cygwin environment. After building the binder tool alongside llvm and clang, the self-tests.py runs with an error of not able to find stddef.h. I am not sure if this is the error of binder tool not able to find the headers or is it a problem with cygwin environment.

T00.basic.hpp Compiling binding results...
cd /home/sramachandran/binder/test/build/ && clang++ -O3 -shared -std=c++11 -I /home/sramachandran/binder/build/pybind11/include -I/usr/include/python3.6m -I./.. -I./../.. -I./../../source T00_basic.cpp -o T00_basic.so
In file included from T00_basic.cpp:9:
In file included from /home/sramachandran/binder/build/pybind11/include/pybind11/pybind11.h:43:
In file included from /home/sramachandran/binder/build/pybind11/include/pybind11/attr.h:13:
In file included from /home/sramachandran/binder/build/pybind11/include/pybind11/cast.h:13:
In file included from /home/sramachandran/binder/build/pybind11/include/pybind11/pytypes.h:12:
In file included from /home/sramachandran/binder/build/pybind11/include/pybind11/detail/common.h:111:
In file included from /usr/include/python3.6m/Python.h:11:
In file included from /usr/include/limits.h:11:
In file included from /usr/include/features.h:12:
/usr/include/sys/cdefs.h:45:10: fatal error: 'stddef.h' file not found
#include <stddef.h>
         ^~~~~~~~~~
1 error generated.

Encounter error while executing: cd /home/sramachandran/binder/test/build/ && clang++ -O3 -shared -std=c++11 -I /home/sramachandran/binder/build/pybind11/include -I/usr/include/python3.6m -I./.. -I./../.. -I./../../source T00_basic.cpp -o T00_basic.so

Encounter error while executing: cd /home/sramachandran/binder/test/build/ && clang++ -O3 -shared -std=c++11 -I /home/sramachandran/binder/build/pybind11/include -I/usr/include/python3.6m -I./.. -I./../.. -I./../../source T00_basic.cpp -o T00_basic.so
In file included from T00_basic.cpp:9:
In file included from /home/sramachandran/binder/build/pybind11/include/pybind11/pybind11.h:43:
In file included from /home/sramachandran/binder/build/pybind11/include/pybind11/attr.h:13:
In file included from /home/sramachandran/binder/build/pybind11/include/pybind11/cast.h:13:
In file included from /home/sramachandran/binder/build/pybind11/include/pybind11/pytypes.h:12:
In file included from /home/sramachandran/binder/build/pybind11/include/pybind11/detail/common.h:111:
In file included from /usr/include/python3.6m/Python.h:11:
In file included from /usr/include/limits.h:11:
In file included from /usr/include/features.h:12:
/usr/include/sys/cdefs.h:45:10: fatal error: 'stddef.h' file not found
#include <stddef.h>
         ^~~~~~~~~~
1 error generated.

Encounter error while executing: cd /home/sramachandran/binder/test && ./self-test.py --binder /home/sramachandran/binder/build/llvm-4.0/build_release_40.cygwin.MTL-BE037.release/bin/binder --pybind11 /home/sramachandran/binder/build/pybind11/include

Encounter error while executing: cd /home/sramachandran/binder/test && ./self-test.py --binder /home/sramachandran/binder/build/llvm-4.0/build_release_40.cygwin.MTL-BE037.release/bin/binder --pybind11 /home/sramachandran/binder/build/pybind11/include
Removing old test dir /home/sramachandran/binder/test/build/ ...
T00.basic.hpp Running test...
/home/sramachandran/binder/build/llvm-4.0/build_release_40.cygwin.MTL-BE037.release/bin/binder --bind "" --root-module T00_basic --prefix /home/sramachandran/binder/test/build/ --single-file --annotate-includes  /home/sramachandran/binder/test/build//T00.basic.hpp.include -- -x c++ -std=c++11 -I /home/sramachandran/binder/test -I /home/sramachandran/binder/test/..
Generate bindings, pass 1...
Generate bindings, pass 2...
Sorting Binders...
Sorting Binders... Done.
Writing code...
Writing code... Done.

T00.basic.hpp Compiling binding results...
cd /home/sramachandran/binder/test/build/ && clang++ -O3 -shared -std=c++11 -I /home/sramachandran/binder/build/pybind11/include -I/usr/include/python3.6m -I./.. -I./../.. -I./../../source T00_basic.cpp -o T00_basic.so
In file included from T00_basic.cpp:9:
In file included from /home/sramachandran/binder/build/pybind11/include/pybind11/pybind11.h:43:
In file included from /home/sramachandran/binder/build/pybind11/include/pybind11/attr.h:13:
In file included from /home/sramachandran/binder/build/pybind11/include/pybind11/cast.h:13:
In file included from /home/sramachandran/binder/build/pybind11/include/pybind11/pytypes.h:12:
In file included from /home/sramachandran/binder/build/pybind11/include/pybind11/detail/common.h:111:
In file included from /usr/include/python3.6m/Python.h:11:
In file included from /usr/include/limits.h:11:
In file included from /usr/include/features.h:12:
/usr/include/sys/cdefs.h:45:10: fatal error: 'stddef.h' file not found
#include <stddef.h>
         ^~~~~~~~~~
1 error generated.

Encounter error while executing: cd /home/sramachandran/binder/test/build/ && clang++ -O3 -shared -std=c++11 -I /home/sramachandran/binder/build/pybind11/include -I/usr/include/python3.6m -I./.. -I./../.. -I./../../source T00_basic.cpp -o T00_basic.so

Encounter error while executing: cd /home/sramachandran/binder/test/build/ && clang++ -O3 -shared -std=c++11 -I /home/sramachandran/binder/build/pybind11/include -I/usr/include/python3.6m -I./.. -I./../.. -I./../../source T00_basic.cpp -o T00_basic.so
In file included from T00_basic.cpp:9:
In file included from /home/sramachandran/binder/build/pybind11/include/pybind11/pybind11.h:43:
In file included from /home/sramachandran/binder/build/pybind11/include/pybind11/attr.h:13:
In file included from /home/sramachandran/binder/build/pybind11/include/pybind11/cast.h:13:
In file included from /home/sramachandran/binder/build/pybind11/include/pybind11/pytypes.h:12:
In file included from /home/sramachandran/binder/build/pybind11/include/pybind11/detail/common.h:111:
In file included from /usr/include/python3.6m/Python.h:11:
In file included from /usr/include/limits.h:11:
In file included from /usr/include/features.h:12:
/usr/include/sys/cdefs.h:45:10: fatal error: 'stddef.h' file not found
#include <stddef.h>
         ^~~~~~~~~~
1 error generated.

Is it really necessary to build llvm and clang to build Binder? Is it not possible to use the existing or already built binaries of llvm and clang to build binder?

Regards,

0K

lyskov commented 6 years ago

Re cygwin build: this behavior is expected: cygwin create its own unix-like environment with its own C++ std libs, path etc. So i doubt that such build will be possible to use outside of such environment.

@aalavandhaann have you tried build native windows build of LLVM? I think some of the developer was able to so before. From what i can gather from https://llvm.org/docs/GettingStartedVS.html it looks like the idea is to install native Windows version CMake (not a cygwin), then make it generate MSVC project files and then run MSVC IDE to build code. In case of the binder it will be almost the same except you will need to double check that MSVC project for binder is generated correctly.

@aalavandhaann, if you going to try steps above: if you interested and can document step-by-step instruction and create PR that will add documentation page for how-to-build-on-windows - it will be great and such PR will be very welcome!

aalavandhaann commented 6 years ago

@lyskov ,

I was able to compile LLVM and CLANG but not Binder using Visual Studio. The binder source had a lot of 'or', 'and', 'not' etc.,. I am replacing them with pipes, ambersands and exclamation symbols. Will keep you posted about it.

Regards,

0K

aalavandhaann commented 6 years ago

@lyskov ,

I am happy to say that binder has been compiled succesfully on Windows 7. Also I was able to generate a binding file for the same project that I was originally doing on Ubuntu. There were some tiny tiny things that made me go haywire but yes, finally it worked. Do you know if building a binary on a windows machine can be made shareable? If the binaries are shared will it work for others?

Regards,

0K

lyskov commented 6 years ago

Re and/or/xor operators: This is known problem with Microsoft compilers. For some reasons by default they are disabled, please see https://msdn.microsoft.com/en-us/library/0k0w269d.aspx for how to enable them.

Re share binary: I not 100% sure, but i would say yes, its very likely that statically linked executables will work on other windows machines. But if you figured out how to compile native build on Windows it might be even better to just put that in writing and i will add this to documentation. (shared binaries have a problem that it is quickly became outdated and it is also impose potential security hazard)

lyskov commented 6 years ago

btw, out of curiosity: have you tried using Clang Windows binaries to compile LLVM? Looks like LLVM made them available here: http://releases.llvm.org/download.html

aalavandhaann commented 6 years ago

@lyskov ,

I followed the steps on the link you gave me four comments earlier. I did two things in addition to those steps in the Visual Studio IDE 1 - Selected the sources files of Binder with 'or', 'and', 'not' etc. In their configuration menu (upon right click->c/c++ options) I selected Disable Language Extensions to Yes (/Za).

2 - The compilation had another error of missing 'atlbase.h'. I found out that this header is now shipped inside the directory "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\include"

I did those two steps to compile binder sucessfully.

Regards,

0K

aalavandhaann commented 6 years ago

Looks like binder is complying with the latest version of pybind11, really happy to see that.

If I try using the generated file (generates without errors if std=c++14 is used) this is the output log of compilation.

I used python setup.py build

chenhancc-WIN.cpp
chenhancc/chenhancc-WIN.cpp(728): error C2039: 'function': is not a member of 'std'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\valarray(15): note: see declaration of 'std'
chenhancc/chenhancc-WIN.cpp(728): error C2065: 'function': undeclared identifier

chenhancc/chenhancc-WIN.cpp(728): error C2275: 'pybind11::module': illegal use of this type as an expression
chenhancc/chenhancc-WIN.cpp(728): note: see declaration of 'pybind11::module'
chenhancc/chenhancc-WIN.cpp(728): error C2146: syntax error: missing ')' before
identifier 'namespace_'
chenhancc/chenhancc-WIN.cpp(728): error C2065: 'namespace_': undeclared identifi
er
chenhancc/chenhancc-WIN.cpp(728): error C2182: 'bind_std_xtr1common': illegal us
e of type 'void'
chenhancc/chenhancc-WIN.cpp(728): error C2143: syntax error: missing ';' before
'>'
chenhancc/chenhancc-WIN.cpp(728): error C2059: syntax error: '>'
chenhancc/chenhancc-WIN.cpp(728): error C2059: syntax error: ')'
chenhancc/chenhancc-WIN.cpp(729): error C2143: syntax error: missing ';' before
'{'
chenhancc/chenhancc-WIN.cpp(729): error C2447: '{': missing function header (old
-style formal list?)
chenhancc/chenhancc-WIN.cpp(1507): error C2039: 'function': is not a member of '
std'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\valarray(15): not
e: see declaration of 'std'
chenhancc/chenhancc-WIN.cpp(1507): error C2065: 'function': undeclared identifie
r
chenhancc/chenhancc-WIN.cpp(1507): error C2275: 'pybind11::module': illegal use
of this type as an expression
chenhancc/chenhancc-WIN.cpp(1507): note: see declaration of 'pybind11::module'
chenhancc/chenhancc-WIN.cpp(1507): error C2146: syntax error: missing ')' before
 identifier 'namespace_'
chenhancc/chenhancc-WIN.cpp(1507): error C2065: 'namespace_': undeclared identif
ier
chenhancc/chenhancc-WIN.cpp(1507): error C2182: 'bind_std_xutility': illegal use
 of type 'void'
chenhancc/chenhancc-WIN.cpp(1507): error C2143: syntax error: missing ';' before
 '>'
chenhancc/chenhancc-WIN.cpp(1507): error C2059: syntax error: '>'
chenhancc/chenhancc-WIN.cpp(1507): error C2059: syntax error: ')'
chenhancc/chenhancc-WIN.cpp(1508): error C2143: syntax error: missing ';' before
 '{'
chenhancc/chenhancc-WIN.cpp(1508): error C2447: '{': missing function header (ol
d-style formal list?)
chenhancc/chenhancc-WIN.cpp(2195): error C2039: 'function': is not a member of '
std'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\valarray(15): not
e: see declaration of 'std'
chenhancc/chenhancc-WIN.cpp(2195): error C2065: 'function': undeclared identifie
r
chenhancc/chenhancc-WIN.cpp(2195): error C2275: 'pybind11::module': illegal use
of this type as an expression
chenhancc/chenhancc-WIN.cpp(2195): note: see declaration of 'pybind11::module'
chenhancc/chenhancc-WIN.cpp(2195): error C2146: syntax error: missing ')' before
 identifier 'namespace_'
chenhancc/chenhancc-WIN.cpp(2195): error C2065: 'namespace_': undeclared identif
ier
chenhancc/chenhancc-WIN.cpp(2195): error C2182: 'bind_std_xmemory0': illegal use
 of type 'void'
chenhancc/chenhancc-WIN.cpp(2195): error C2143: syntax error: missing ';' before
 '>'
chenhancc/chenhancc-WIN.cpp(2195): error C2059: syntax error: '>'
chenhancc/chenhancc-WIN.cpp(2195): error C2059: syntax error: ')'
chenhancc/chenhancc-WIN.cpp(2196): error C2143: syntax error: missing ';' before
 '{'
chenhancc/chenhancc-WIN.cpp(2196): error C2447: '{': missing function header (ol
d-style formal list?)
chenhancc/chenhancc-WIN.cpp(3127): error C2039: 'function': is not a member of '
std'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\valarray(15): not
e: see declaration of 'std'
chenhancc/chenhancc-WIN.cpp(3127): error C2065: 'function': undeclared identifie
r
chenhancc/chenhancc-WIN.cpp(3127): error C2275: 'pybind11::module': illegal use
of this type as an expression
chenhancc/chenhancc-WIN.cpp(3127): note: see declaration of 'pybind11::module'
chenhancc/chenhancc-WIN.cpp(3127): error C2146: syntax error: missing ')' before
 identifier 'namespace_'
chenhancc/chenhancc-WIN.cpp(3127): error C2065: 'namespace_': undeclared identif
ier
chenhancc/chenhancc-WIN.cpp(3127): error C2182: 'bind_std_vector': illegal use o
f type 'void'
chenhancc/chenhancc-WIN.cpp(3127): error C2143: syntax error: missing ';' before
 '>'
chenhancc/chenhancc-WIN.cpp(3127): error C2059: syntax error: '>'
chenhancc/chenhancc-WIN.cpp(3127): error C2059: syntax error: ')'
chenhancc/chenhancc-WIN.cpp(3128): error C2143: syntax error: missing ';' before
 '{'
chenhancc/chenhancc-WIN.cpp(3128): error C2447: '{': missing function header (ol
d-style formal list?)
chenhancc/chenhancc-WIN.cpp(3325): error C2039: 'function': is not a member of '
std'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\valarray(15): not
e: see declaration of 'std'
chenhancc/chenhancc-WIN.cpp(3325): error C2065: 'function': undeclared identifie
r
chenhancc/chenhancc-WIN.cpp(3325): error C2275: 'pybind11::module': illegal use
of this type as an expression
chenhancc/chenhancc-WIN.cpp(3325): note: see declaration of 'pybind11::module'
chenhancc/chenhancc-WIN.cpp(3325): error C2146: syntax error: missing ')' before
 identifier 'namespace_'
chenhancc/chenhancc-WIN.cpp(3325): error C2065: 'namespace_': undeclared identif
ier
chenhancc/chenhancc-WIN.cpp(3325): error C2182: 'bind_std_xtree': illegal use of
 type 'void'
chenhancc/chenhancc-WIN.cpp(3325): error C2143: syntax error: missing ';' before
 '>'
chenhancc/chenhancc-WIN.cpp(3325): error C2059: syntax error: '>'
chenhancc/chenhancc-WIN.cpp(3325): error C2059: syntax error: ')'
chenhancc/chenhancc-WIN.cpp(3326): error C2143: syntax error: missing ';' before
 '{'
chenhancc/chenhancc-WIN.cpp(3326): error C2447: '{': missing function header (ol
d-style formal list?)
chenhancc/chenhancc-WIN.cpp(3475): error C2039: 'function': is not a member of '
std'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\valarray(15): not
e: see declaration of 'std'
chenhancc/chenhancc-WIN.cpp(3475): error C2065: 'function': undeclared identifie
r
chenhancc/chenhancc-WIN.cpp(3475): error C2275: 'pybind11::module': illegal use
of this type as an expression
chenhancc/chenhancc-WIN.cpp(3475): note: see declaration of 'pybind11::module'
chenhancc/chenhancc-WIN.cpp(3475): error C2146: syntax error: missing ')' before
 identifier 'namespace_'
chenhancc/chenhancc-WIN.cpp(3475): error C2065: 'namespace_': undeclared identif
ier
chenhancc/chenhancc-WIN.cpp(3475): error C2182: 'bind_std_xtree_1': illegal use
of type 'void'
chenhancc/chenhancc-WIN.cpp(3475): error C2143: syntax error: missing ';' before
 '>'
chenhancc/chenhancc-WIN.cpp(3475): error C2059: syntax error: '>'
chenhancc/chenhancc-WIN.cpp(3475): error C2059: syntax error: ')'
chenhancc/chenhancc-WIN.cpp(3476): error C2143: syntax error: missing ';' before
 '{'
chenhancc/chenhancc-WIN.cpp(3476): error C2447: '{': missing function header (ol
d-style formal list?)
chenhancc/chenhancc-WIN.cpp(3577): error C2039: 'function': is not a member of '
std'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\valarray(15): not
e: see declaration of 'std'
chenhancc/chenhancc-WIN.cpp(3577): error C2065: 'function': undeclared identifie
r
chenhancc/chenhancc-WIN.cpp(3577): error C2275: 'pybind11::module': illegal use
of this type as an expression
chenhancc/chenhancc-WIN.cpp(3577): note: see declaration of 'pybind11::module'
chenhancc/chenhancc-WIN.cpp(3577): error C2146: syntax error: missing ')' before
 identifier 'namespace_'
chenhancc/chenhancc-WIN.cpp(3577): error C2065: 'namespace_': undeclared identif
ier
chenhancc/chenhancc-WIN.cpp(3577): error C2182: 'bind_std_set': illegal use of t
ype 'void'
chenhancc/chenhancc-WIN.cpp(3577): error C2143: syntax error: missing ';' before
 '>'
chenhancc/chenhancc-WIN.cpp(3577): error C2059: syntax error: '>'
chenhancc/chenhancc-WIN.cpp(3577): error C2059: syntax error: ')'
chenhancc/chenhancc-WIN.cpp(3578): error C2143: syntax error: missing ';' before
 '{'
chenhancc/chenhancc-WIN.cpp(3578): error C2447: '{': missing function header (ol
d-style formal list?)
chenhancc/chenhancc-WIN.cpp(3847): error C2039: 'function': is not a member of '
std'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\valarray(15): not
e: see declaration of 'std'
chenhancc/chenhancc-WIN.cpp(3847): error C2065: 'function': undeclared identifie
r
chenhancc/chenhancc-WIN.cpp(3847): error C2275: 'pybind11::module': illegal use
of this type as an expression
chenhancc/chenhancc-WIN.cpp(3847): note: see declaration of 'pybind11::module'
chenhancc/chenhancc-WIN.cpp(3847): error C2146: syntax error: missing ')' before
 identifier 'namespace_'
chenhancc/chenhancc-WIN.cpp(3847): error C2065: 'namespace_': undeclared identif
ier
chenhancc/chenhancc-WIN.cpp(3847): error C2182: 'bind_Point3D': illegal use of t
ype 'void'
chenhancc/chenhancc-WIN.cpp(3847): error C2143: syntax error: missing ';' before
 '>'
chenhancc/chenhancc-WIN.cpp(3847): error C2059: syntax error: '>'
chenhancc/chenhancc-WIN.cpp(3847): error C2059: syntax error: ')'
chenhancc/chenhancc-WIN.cpp(3848): error C2143: syntax error: missing ';' before
 '{'
chenhancc/chenhancc-WIN.cpp(3848): error C2447: '{': missing function header (ol
d-style formal list?)
C:/Users/sramachandran/Documents/chenhancc/distribution_files/chenhancc/ICHWithF
urtherPriorityQueue.hpp(189): warning C4244: '=': conversion from 'unsigned __in
t64' to 'double', possible loss of data
chenhancc/chenhancc-WIN.cpp(4663): error C2039: 'function': is not a member of '
std'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\valarray(15): not
e: see declaration of 'std'
chenhancc/chenhancc-WIN.cpp(4663): error C2065: 'function': undeclared identifie
r
chenhancc/chenhancc-WIN.cpp(4663): error C2275: 'pybind11::module': illegal use
of this type as an expression
chenhancc/chenhancc-WIN.cpp(4663): note: see declaration of 'pybind11::module'
chenhancc/chenhancc-WIN.cpp(4663): error C2146: syntax error: missing ')' before
 identifier 'namespace_'
chenhancc/chenhancc-WIN.cpp(4663): error C2065: 'namespace_': undeclared identif
ier
chenhancc/chenhancc-WIN.cpp(4663): error C2182: 'bind_RichModel': illegal use of
 type 'void'
chenhancc/chenhancc-WIN.cpp(4663): error C2143: syntax error: missing ';' before
 '>'
chenhancc/chenhancc-WIN.cpp(4663): error C2059: syntax error: '>'
chenhancc/chenhancc-WIN.cpp(4663): error C2059: syntax error: ')'
chenhancc/chenhancc-WIN.cpp(4664): error C2143: syntax error: missing ';' before
 '{'
chenhancc/chenhancc-WIN.cpp(4664): error C2447: '{': missing function header (ol
d-style formal list?)
chenhancc/chenhancc-WIN.cpp(4814): error C2365: 'bind_std_xtr1common': redefinit
ion; previous definition was 'data variable'
chenhancc/chenhancc-WIN.cpp(728): note: see declaration of 'bind_std_xtr1common'

chenhancc/chenhancc-WIN.cpp(4815): error C2365: 'bind_std_xutility': redefinitio
n; previous definition was 'data variable'
chenhancc/chenhancc-WIN.cpp(1507): note: see declaration of 'bind_std_xutility'
chenhancc/chenhancc-WIN.cpp(4815): fatal error C1003: error count exceeds 100; s
topping compilation
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\
x86_amd64\\cl.exe' failed with exit status 2

Any ideas?

Regards,

0K

lyskov commented 6 years ago

core of this is probably in chenhancc/chenhancc-WIN.cpp(728): error C2039: 'function': is not a member of 'std' error. I would suggest to re-run Binder with --annotate-includes flag and check why <functional> header is not included. This is most likely due to Binder tries to include some underlying MS headers instead. Locate such includes then alter type.cpp function add_relevant_include_for_decl to add proper mapping for such includes.

aalavandhaann commented 6 years ago

The cpp is already annotated with --annotate-includes flag. Perhaps I can attach the file here chenhancc-WIN.txt

The annotation for @include<functional> is blank. Hence I am not sure why this has not been included. Also I was looking into the type.cpp method add_relevant_include_for_decl so I can understand and add the proper mapping. There are two variables name_map and include_map

name_map

static vector< std::pair<string, string> > const name_map = {
        make_pair("std::allocator",        "<memory>"),
        make_pair("std::basic_string",     "<string>"),
        make_pair("std::char_traits",      "<string>"),
        make_pair("std::iterator",         "<iterator>"),
        make_pair("std::list",             "<list>"),
        make_pair("std::locale",           "<locale>"),
        make_pair("std::map",              "<map>"),
        make_pair("std::pair",             "<utility>"),
        make_pair("std::reverse_iterator", "<iterator>"),
        make_pair("std::set",              "<set>"),
        make_pair("std::vector",           "<vector>"),
        make_pair("std::basic_ios",        "<ios>"),

        make_pair("__gnu_cxx::__normal_iterator", "<iterator>"),

        make_pair("std::__1::basic_string<char,std::__1::char_traits<char>,std::__1::allocator<char>>", "<string>"),
        make_pair("std::__1::basic_streambuf<char,std::__1::char_traits<char>>",                        "<streambuf>"),
        make_pair("std::__1::basic_istream<char,std::__1::char_traits<char>>",                          "<istream>"),
        make_pair("std::__1::basic_iostream<char,std::__1::char_traits<char>>",                         "<ostream>"),
    };

include_map

static vector< std::pair<string, string> > const include_map = {
        make_pair("<bits/ios_base.h>",     "<ios>"),
        make_pair("<bits/istream.tcc>",    "<istream>"),
        make_pair("<bits/ostream.tcc>",    "<ostream>"),
        make_pair("<bits/postypes.h>",     "<ios>"),

        make_pair("<bits/stl_function.h>", "<functional>"),
        make_pair("<bits/stl_tree.h>",     "<map>"),
        make_pair("<bits/stl_map.h>",      "<map>"),
        make_pair("<bits/streambuf.tcc>",  "<streambuf>"),
        make_pair("<bits/stl_bvector.h>",  "<vector>"),
        make_pair("<bits/stl_vector.h>",   "<vector>"),
        make_pair("<bits/algorithmfwd.h>", "<algorithm>"),
        make_pair("<bits/stl_algo.h>",     "<algorithm>"),
        make_pair("<bits/fstream.tcc>",    "<fstream>"),
        make_pair("<bits/sstream.tcc>",    "<sstream>"),
        make_pair("<bits/stl_list.h>",     "<list>"),
        make_pair("<bits/stl_deque.h>",    "<deque>"),
        make_pair("<bits/stl_queue.h>",    "<queue>"),
        make_pair("<bits/sched.h>",        "<unistd.h>"),
        make_pair("<bits/pthreadtypes.h>", "<pthread.h>"),
        make_pair("<bits/gthr-default.h>", "<pthread.h>"),
        make_pair("<bits/random.h>",       "<random>"),

        make_pair("<bits/basic_string.h>",  "<string>"),
        make_pair("<bits/basic_string.tcc>","<string>"),
        make_pair("<bits/streambuf_iterator.h>", "<streambuf>"),

        make_pair("<bits/shared_ptr.h>",      "<memory>"),
        make_pair("<bits/unique_ptr.h>",      "<memory>"),
        make_pair("<bits/uses_allocator.h>",  "<memory>"),
        make_pair("<bits/shared_ptr_base.h>", "<memory>"),
        make_pair("<backward/auto_ptr.h>",    "<memory>"),
        make_pair("<ext/concurrence.h>",      "<memory>"),
        make_pair("<bits/ptr_traits.h>",      "<memory>"),
        make_pair("<bits/alloc_traits.h>",    "<memory>"),

        make_pair("<bits/error_constants.h>", "<system_error>"),

        make_pair("<bits/locale_classes.h>",   "<locale>"),
        make_pair("<bits/locale_classes.tcc>", "<locale>"),

        make_pair("<__tree>",              "<iterator>"),
        make_pair("<bits/stl_iterator.h>", "<iterator>"),

        make_pair("<__functional_base>", "<functional>"),

        make_pair("<_wctype.h>", "<cwctype>"),
        make_pair("<ctype.h>",   "<cctype>"),
        make_pair("<wchar.h>",   "<cwchar>"),

        make_pair("<bits/functional_hash.h>", "<functional>"),
        make_pair("<bits/unordered_set.h>",   "<unordered_set>"),
        make_pair("<bits/unordered_map.h>",   "<unordered_map>"),

        make_pair("<bits/stl_multiset.h>", "<set>"),
        make_pair("<bits/stl_multimap.h>", "<map>"),

        //make_pair("<bits/hashtable_policy.h>", could be either unordered_map or unordered_set
        make_pair("<bits/hashtable_policy.h>", "<unordered_map>"),

        make_pair("<__locale>", "<locale>"),

        make_pair("<__bit_reference>", "<vector>"),

    };

I can see that functional has repeated itself thrice in the include_map and none in name_map. Is this normal? Any ideas what should be done here?

Also I tried to do a diff between the GCC version of the generated file versus the WINdows version of the generated file (chenhancc-GCC.cpp vs chenhann-Win.cpp). The windows version is bloated in size and there are many repeated includes. At a glance that is what I could see. I am not sure if this direction is helpful.

Regards,

0K

lyskov commented 6 years ago

I can see that functional has repeated itself thrice in the include_map and none in name_map. Is this normal?

I have looked at generated source file that you posted and i have a few questions:

aalavandhaann commented 6 years ago

Yes, all the .hpp files are mine. The files xmemory0, xstring, xtr1common are all from MS Implementations of std libs. I think its possible to look into those files and create a map if necessary. Do you have a doc or link that explains this 'mapping' effort? If I better understand then I might be able to do something. If this is the thing stopping binder to work on windows, then I am ready to shell in energy to make it work. Thanks a lot for your guidance so far. But let me know what needs to be done with the include_map and I will try to do so.

Regards,

0K

lyskov commented 6 years ago

The include_map should be pretty self explanatory: you map system-std-includes to standard C++ includes. For example if header xmemory0 declare std::shared_ptr class then it should be mapped to <memory>.