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

Add windows build support #781

Closed
wants to merge 2 commits into from
Closed

Add windows build support #781

wants to merge 2 commits into from

Conversation

Toilal
Copy link

@Toilal Toilal commented Mar 11, 2020

This should fix #476 and is a first step for #734 by fixing CMake.

With this PR, python extension build is now performed by either CMake, make or distutils compiler using a fallback strategy. (It will try using CMake first, then make, and fallback to distutils compiler).

CMake has been modifier to accept the build to run with MSVC compilet (tested on Windows with Visual C++ Build Tools v14.2)

Here's the command to run on windows to build.

cmake . -Bbuild && cmake --build build --config Release

Release files are then available in build/Release

There's still linker errors when, but exe files are available and works properly, any help welcome about those errors (I'm not a C/C++ developer). (maybe it's related to #778)

libjsonnet++.obj : error LNK2019: symbole externe non rÚsolu jsonnet_version rÚfÚrencÚ dans la fonction "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >__cdecl jsonnet::Jsonnet::version(void)" (?version@Jsonnet@jsonnet@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) [C:\Users\xxx\projects\jsonnet\build\cpp\libjsonnet++.vcxproj]
libjsonnet++.obj : error LNK2019: symbole externe non rÚsolu jsonnet_make rÚfÚrencÚ dans la fonction "public: bool __cdecl jsonnet::Jsonnet::init(void)" (?init@Jsonnet@jsonnet@@QEAA_NXZ) [C:\Users\xxx\p rojects\jsonnet\build\cpp\libjsonnet++.vcxproj]
libjsonnet++.obj : error LNK2019: symbole externe non rÚsolu jsonnet_max_stack rÚfÚrencÚ dans la fonction "public: void __cdecl jsonnet::Jsonnet::setMaxStack(unsigned int)" (?setMaxStack@Jsonnet@jsonnet@@QEAA XI@Z) [C:\Users\xxx\projects\jsonnet\build\cpp\libjsonnet++.vcxproj]
libjsonnet++.obj : error LNK2019: symbole externe non rÚsolu jsonnet_gc_min_objects rÚfÚrencÚ dans la fonction "public: void __cdecl jsonnet::Jsonnet::setGcMinObjects(unsigned int)" (?setGcMinObjects@Jsonnet@ jsonnet@@QEAAXI@Z) [C:\Users\xxx\projects\jsonnet\build\cpp\libjsonnet++.vcxproj]
libjsonnet++.obj : error LNK2019: symbole externe non rÚsolu jsonnet_gc_growth_trigger rÚfÚrencÚ dans la fonction "public: void __cdecl jsonnet::Jsonnet::setGcGrowthTrigger(double)" (?setGcGrowthTrigger@Jsonn et@jsonnet@@QEAAXN@Z) [C:\Users\xxx\projects\jsonnet\build\cpp\libjsonnet++.vcxproj]
libjsonnet++.obj : error LNK2019: symbole externe non rÚsolu jsonnet_string_output rÚfÚrencÚ dans la fonction "public: void __cdecl jsonnet::Jsonnet::setStringOutput(bool)" (?setStringOutput@Jsonnet@jsonnet@@ QEAAX_N@Z) [C:\Users\xxx\projects\jsonnet\build\cpp\libjsonnet++.vcxproj]
libjsonnet++.obj : error LNK2019: symbole externe non rÚsolu jsonnet_ext_var rÚfÚrencÚ dans la fonction "public: void __cdecl jsonnet::Jsonnet::bindExtVar(class std::basic_string<char,struct std::char_traits< char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?bindExtVar@Jsonnet@jsonnet@@QEAAXAEBV?$basic_string@DU?$char_trai ts@D@std@@V?$allocator@D@2@@std@@0@Z) [C:\Users\xxx\projects\jsonnet\build\cpp\libjsonnet++.vcxproj]
libjsonnet++.obj : error LNK2019: symbole externe non rÚsolu jsonnet_ext_code rÚfÚrencÚ dans la fonction "public: void __cdecl jsonnet::Jsonnet::bindExtCodeVar(class std::basic_string<char,struct std::char_tr aits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?bindExtCodeVar@Jsonnet@jsonnet@@QEAAXAEBV?$basic_string@DU?$ char_traits@D@std@@V?$allocator@D@2@@std@@0@Z) [C:\Users\xxx\projects\jsonnet\build\cpp\libjsonnet++.vcxproj]
libjsonnet++.obj : error LNK2019: symbole externe non rÚsolu jsonnet_tla_var rÚfÚrencÚ dans la fonction "public: void __cdecl jsonnet::Jsonnet::bindTlaVar(class std::basic_string<char,struct std::char_traits< char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?bindTlaVar@Jsonnet@jsonnet@@QEAAXAEBV?$basic_string@DU?$char_trai ts@D@std@@V?$allocator@D@2@@std@@0@Z) [C:\Users\xxx\projects\jsonnet\build\cpp\libjsonnet++.vcxproj]
libjsonnet++.obj : error LNK2019: symbole externe non rÚsolu jsonnet_tla_code rÚfÚrencÚ dans la fonction "public: void __cdecl jsonnet::Jsonnet::bindTlaCodeVar(class std::basic_string<char,struct std::char_tr aits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?bindTlaCodeVar@Jsonnet@jsonnet@@QEAAXAEBV?$basic_string@DU?$ char_traits@D@std@@V?$allocator@D@2@@std@@0@Z) [C:\Users\xxx\projects\jsonnet\build\cpp\libjsonnet++.vcxproj]
libjsonnet++.obj : error LNK2019: symbole externe non rÚsolu jsonnet_max_trace rÚfÚrencÚ dans la fonction "public: void __cdecl jsonnet::Jsonnet::setMaxTrace(unsigned int)" (?setMaxTrace@Jsonnet@jsonnet@@QEAA XI@Z) [C:\Users\xxx\projects\jsonnet\build\cpp\libjsonnet++.vcxproj]
libjsonnet++.obj : error LNK2019: symbole externe non rÚsolu jsonnet_jpath_add rÚfÚrencÚ dans la fonction "public: void __cdecl jsonnet::Jsonnet::addImportPath(class std::basic_string<char,struct std::char_tr aits<char>,class std::allocator<char> > const &)" (?addImportPath@Jsonnet@jsonnet@@QEAAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) [C:\Users\xxx\projects\jsonnet\build\cpp\libj sonnet++.vcxproj]
libjsonnet++.obj : error LNK2019: symbole externe non rÚsolu jsonnet_evaluate_file rÚfÚrencÚ dans la fonction "public: bool __cdecl jsonnet::Jsonnet::evaluateFile(class std::basic_string<char,struct std::char _traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?evaluateFile@Jsonnet@jsonnet@@QEAA_NAEBV?$basic_string@DU?$char _traits@D@std@@V?$allocator@D@2@@std@@PEAV34@@Z) [C:\Users\xxx\projects\jsonnet\build\cpp\libjsonnet++.vcxproj]
libjsonnet++.obj : error LNK2019: symbole externe non rÚsolu jsonnet_evaluate_snippet rÚfÚrencÚ dans la fonction "public: bool __cdecl jsonnet::Jsonnet::evaluateSnippet(class std::basic_string<char,struct std ::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?evaluateSnippet@Jsonnet@jsonnet@@QEAA_NAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0PEAV34@@Z) [C:\Users\xxx\projects\jsonnet\build\cpp\libjso nnet++.vcxproj]
libjsonnet++.obj : error LNK2019: symbole externe non rÚsolu jsonnet_evaluate_file_multi rÚfÚrencÚ dans la fonction "public: bool __cdecl jsonnet::Jsonnet::evaluateFileMulti(class std::basic_string<char,struc t std::char_traits<char>,class std::allocator<char> > const &,class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::ch ar_traits<char>,class std::allocator<char> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_s tring<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > *)" (?evaluateFileMulti@Jsonnet@jsonn et@@QEAA_NAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PEAV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocat or@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@4@@Z) [C:\Users\xxx\projects\jsonnet\build\cpp\libjsonnet++.vcxproj]
libjsonnet++.obj : error LNK2019: symbole externe non rÚsolu jsonnet_evaluate_snippet_multi rÚfÚrencÚ dans la fonction "public: bool __cdecl jsonnet::Jsonnet::evaluateSnippetMulti(class std::basic_string<char ,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::map<class std::basic_string<char, struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<class std::basic_string<char,struct std::cha r_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char, struct std::char_traits<char>,class std::allocator<char> > > > > *)" (?evaluateSnippetMulti@Jsonnet@jsonnet@@QEAA_NAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0PEAV?$map@V?$basic_string@D U?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@ @V12@@std@@@2@@4@@Z) [C:\Users\xxx\projects\jsonnet\build\cpp\libjsonnet++.vcxproj]
libjsonnet++.obj : error LNK2019: symbole externe non rÚsolu jsonnet_destroy rÚfÚrencÚ dans la fonction "public: __cdecl jsonnet::Jsonnet::~Jsonnet(void)" (??1Jsonnet@jsonnet@@QEAA@XZ) [C:\Users\xxx\pro jects\jsonnet\build\cpp\libjsonnet++.vcxproj]
C:\Users\xxx\projects\jsonnet\build\Release\jsonnet++.dll : fatal error LNK1120: 17 externes non rÚsolus [C:\Users\xxx\projects\jsonnet\build\cpp\libjsonnet++.vcxproj]

@Toilal Toilal force-pushed the windows branch 2 times, most recently from 6950901 to ffb8c7e Compare March 13, 2020 06:47
This change takes advantage of distutils compiler feature to compile libjsonnet when neither CMake and make are available, or when both CMake and make build are failing.

A fallback strategy to go through this chain of tools (CMake, make, distutils compiler).

This also port stdlib/to_c_array.cpp to pure python to generate std.jsonnet.h.

Python extension can now be build and installed properly on windows and Python 3.5+ when Visual C++ Build Tools are installed.

Windows build on Python 2.7 is still not supported as this version relies on a old version of Visual C++ tools that doesn't support c++11.
@Toilal Toilal force-pushed the windows branch 2 times, most recently from 66e439b to 5475291 Compare March 13, 2020 13:32
@sparkprime
Copy link
Contributor

Those linker errors are for the C++ wrapper which I think it doesn't make sense to build into a DLL because of the binary incompatibility between different C++ compilers.

@Toilal
Copy link
Author

Toilal commented Jan 13, 2021

https://github.com/mcovalt/jsonnetbin just works and seems damn simple. Please take a look at this repository and include the setup.py configuration inside the official project.

@Toilal Toilal closed this Jan 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PIP install failing on Windows 10
4 participants