{"action":"created","issue":{"url":"https://api.github.com/repos/root-project/cling/issues/186","repository_url":"https://api.github.com/repos/root-project/cling","labels_url":"https://api.github.com/repos/root-project/cling/issues/186/labels{/name}","comments_url":"https://api.github.com/repos/root-project/cling/issues/186/comments","events_url":"https://api.github.com/repos/root-project/cling/issues/186/events","html_url":"https://github.com/root-project/cling/issues/186","id":264951399,"number":186,"title":"The (Failed) Adventures in building Cling under Windows 10 with VS2017","user":{"login":"konstantint","id":220083,"avatar_url":"https://avatars1.githubusercontent.com/u/220083?v=4","gravatar_id":"","url":"https://api.github.com/users/konstantint","html_url":"https://github.com/konstantint","followers_url":"https://api.github.com/users/konstantint/followers","following_url":"https://api.github.com/users/konstantint/following{/other_user}","gists_url":"https://api.github.com/users/konstantint/gists{/gist_id}","starred_url":"https://api.github.com/users/konstantint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/konstantint/subscriptions","organizations_url":"https://api.github.com/users/konstantint/orgs","repos_url":"https://api.github.com/users/konstantint/repos","events_url":"https://api.github.com/users/konstantint/events{/privacy}","received_events_url":"https://api.github.com/users/konstantint/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2017-10-12T13:55:03Z","updated_at":"2018-03-21T10:01:47Z","closed_at":null,"author_association":"NONE","body":"One rainy Wednesday evening I was looking for procrastination options and I found them in the form of setting up Cling. Let me tell you this story, hoping it may be useful to either someone planning to repeat this or to work on improving this process.\r\n\r\nI started by searching precompiled Windows binaries. For some reason (why?) the official are not available, but I found the [Anaconda cling package](https://github.com/conda-forge/cling-feedstock). So I tried installing it first:\r\n* `conda create -n cling cling`\r\n\r\nAfter the download was complete I found the `cling` binaries under `Anaconda3\\envs\\cling\\Library\\bin`, however `cling.exe` threw a bunch of warnings and crashed on any nontrivial command.  OK, why not compile Cling myself, right? The night was young.\r\n\r\n* `git clone https://github.com/root-project/cling.git`\r\n* `cd cling\\tools\\packaging`\r\n* Read the README, figure out I need Python 2, OK.\r\n* `conda create -n py27 python=2.7.13`\r\n* `activate`\r\n* `python cpt.py -c`\r\n\r\n  The program prints one error about not being able to read some registry key, but otherwise looks happy. Well, let's try building. Yes, I know it is written you need VS2012 but I only have 2017. Perhaps it will work?\r\n* `python cpt.py --last-stable=pkg` \r\n  \r\n  The program starts preparing the environment and at some point attempts to download CMake. The download succeeds but then some exception is thrown on copying CMake. I look in the code. It turns out the `cmakeDir` variable is used but never declared.\r\n* \"Well, why don't I install CMake normally, I need it anyway, and if I have it installed the code won't even reach the place with `cmakeDir`\". So I go to cmake.org, install CMake using the latest installer, and try again:\r\n* `python cpt.py --last-stable=pkg`\r\n\r\n   Nope, the program does not care about my newly installed cmake and still wants to download one of its own crashing on `cmakeDir` afterwards. I check that `cmake` is in the path, do `set CMAKE=....` just in case. No help. After studying the code a bit more I see that that there's a line which checks CMake version as follows:\r\n\r\n   `vers = [int(v) for v in rslt.split()[2].split('.')]`\r\n   \r\n   This assumes that the version is consisting of three dot-separated integers, whilst my CMake has version `3.10.0-rc1`. Whatever, let's just comment that (and the following) line out and try again!\r\n\r\n* `python cpt.py --last-stable=pkg`\r\n\r\n   Now everything looks fine. CMake configures the project, a long-ish build starts, but fails with some message about an undefined identifier. Googling the error tells me I should not be building with VS2017, but VS2015 could work. Luckily I have the VS2015 build toolchain installed with VS2017 so I only need to let CMake know to use that one by passing the ` -G \"Visual Studio 14 2015 Win64\"` parameter.\r\n\r\n   After some failed attempts to pass it using `--with-cmake-flags` (apparently I'm not good at escaping quotes) I simply hard-code it in `cpt.py` (I've messed around already, so who cares, right?):\r\n   \r\n   `EXTRA_CMAKE_FLAGS = args.get('with_cmake_flags') + ' -G \"Visual Studio 14 2015 Win64\"'`\r\n\r\n* Delete everything under `c:\\ci\\build\\builddir`.\r\n* `python cpt.py --last-stable=pkg`\r\n\r\n  Bad luck. Now CMake cannot configure the project for some reason. After an hour or so of googling, I find out [VC2017 comes with broken VC2015 build tools](https://developercommunity.visualstudio.com/content/problem/22031/unusable-vc-build-tools-2015-installed-with-vs2017.html), and further [hacks](https://github.com/npm/npm/issues/10421#issuecomment-336092786) need to be done to fix this:\r\n\r\n    * Changing a line in `vcvarsall.bat`.\r\n    * Manually setting a `VCTargetsPath` variable.\r\n    * Manually setting the build environment by calling `vcvarsall.bat`.\r\n  \r\n  Fine, on we go!\r\n* `python cpt.py --last-stable=pkg`\r\n\r\n  Now the build fails because of the line `#error \"Unsupported/Untested _MSC_VER\"` somewhere in `PlatformWin.cpp`. Well, we're fine with untested, so let's comment this out.\r\n\r\n* `python cpt.py --last-stable=pkg`\r\n\r\n  Yay, the build step passes now. The `install` fails.\r\n  It turns out that in order to copy the correct files to make the package, `cpt.py` looks for the file `dist-files.txt` under `c:/ci/build/cling-src/tools/cling/tools/packaging`. There's only `dist-files.json`, however. Luckily, the `dist-files.txt` is available in my current directory (the one where *I* checked cling out), so I just copy it to `c:/ci/build/...`.\r\n\r\n* `python cpt.py --last-stable=pkg`\r\n\r\n  OK, now the build and install steps pass, the `test` step fails. The reason seems to be the lack of `cat` command (presumably this would not be a problem if I had MSYS Git set up, but I really don't want to screw my current Git).\r\n  I have `cat` in `cygwin`, so let's try this way:\r\n\r\n* `set PATH=%PATH%;C:\\cygwin64\\bin`\r\n* `python cpt.py --last-stable=pkg`\r\n\r\n  Now I have 16 failing tests, but 98 are passing, so perhaps the failing ones are not that crucial (I won't be using Cling in production). Let's go on. Apparently I need to disable the test step to proceed, though:\r\n\r\n* `python cpt.py --last-stable=pkg --no-test`\r\n\r\n  Next problem comes up in the `make_nsi` step:\r\n\r\n  `UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 166: ordinal not in range(128)`\r\n\r\n  Hmmm... The only non-ASCII symbol in the whole file is ©. Let's replace it with (c) and try again.\r\n\r\n* `python cpt.py --last-stable=pkg --no-test`\r\n\r\n  New milestone: \r\n  `WindowsError: [Error 2] The system cannot find the file specified`.\r\n  However, at this point I actually saw all the necessary files being copied to `c:\\Windows\\Temp\\cling-obj`, so perhaps I could go check out how these worked out.\r\n\r\n* `cd C:\\Windows\\Temp\\cling-obj\\bin`\r\n* `cling.exe`\r\n\r\n  Just like in the Anaconda distribution, I get a bunch of warnings and the shell crashes on any input (except variable declarations and assignments).\r\n\r\nAt this point I gave up. Apparently it's easier to run cling in a docker container at the moment. But maybe I missed some very easy shortcut along the way?"},"comment":{"url":"https://api.github.com/repos/root-project/cling/issues/comments/374885519","html_url":"https://github.com/root-project/cling/issues/186#issuecomment-374885519","issue_url":"https://api.github.com/repos/root-project/cling/issues/186","id":374885519,"user":{"login":"liudonghua123","id":2276718,"avatar_url":"https://avatars3.githubusercontent.com/u/2276718?v=4","gravatar_id":"","url":"https://api.github.com/users/liudonghua123","html_url":"https://github.com/liudonghua123","followers_url":"https://api.github.com/users/liudonghua123/followers","following_url":"https://api.github.com/users/liudonghua123/following{/other_user}","gists_url":"https://api.github.com/users/liudonghua123/gists{/gist_id}","starred_url":"https://api.github.com/users/liudonghua123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liudonghua123/subscriptions","organizations_url":"https://api.github.com/users/liudonghua123/orgs","repos_url":"https://api.github.com/users/liudonghua123/repos","events_url":"https://api.github.com/users/liudonghua123/events{/privacy}","received_events_url":"https://api.github.com/users/liudonghua123/received_events","type":"User","site_admin":false},"created_at":"2018-03-21T10:01:47Z","updated_at":"2018-03-21T10:01:47Z","author_association":"NONE","body":"@bellenot I modified `tools/driver/CMakeLists.txt`, and I am building. Later I will test again."}}
{"actor":{"display_login":"liudonghua123"}}