jasongin / noble-uwp

Noble (Node.js Bluetooth LE) with Windows 10 UWP bindings
MIT License
83 stars 45 forks source link

ERror building #1

Closed farfromrefug closed 7 years ago

farfromrefug commented 7 years ago

Hi, I am trying your module. I have win 10 Insider 10.0.15042.0 with the SDK. Though it won't build:

..\_nodert_generated.cpp(64): error C2039: 'BluetoothAdapter': is not a member of 'Windows::Devices::Bluetooth' [C:\Users\mguillon\dev\aryballe\noble-uwp\uwp\windows.devices .bluetooth\build\binding.vcxproj]

I guess this is because it actually builds with VC14 and not VC17. How did you get node-gyp to use VC17?

BTW i forked your repo and already refactored the gyp files to prevent duplicate and to make it easier to update the win SDK version. I can make a PR if you want

vohtaski commented 7 years ago

imho, PR would be cool, so that windows build has to be changed in one place :)

farfromrefug commented 7 years ago

PR created. @jasongin could you help me with the build error? Thanks

jasongin commented 7 years ago

Sorry I must have missed the notification when this issue was first opened.

VC17 or updated node-gyp should not be required to build. From the error above, it looks like it is not finding the right version of WinRT metadata. Could it be related to the refactoring you did?

I will try to investigate more later today.

jasongin commented 7 years ago

Oh, you do have to specify --msvs_version=2015 with node-gyp. And that requires VC 2015.

Did you try using the build.cmd script? Or npm install which calls it? That should build everything correctly if you have the necessary prereqs installed.

I checked and there have been no changes to WinRT APIs in the imported namespaces between SDK versions 10.0.15021 (the version currently referenced in the sources) and version 10.0.15052 (the latest available version). So any version within that range should work by just updating the version references.

jasongin commented 7 years ago

BTW, if you start working with this project / hacking on it, note there is a develop branch that has a few additional changes, that are not yet tested as well.

I haven't had much time to work on this project recently but I hope to get back to it soon.

farfromrefug commented 7 years ago

@jasongin Yes did not see that! Do you want me to cose that PR and open it on develop?

jasongin commented 7 years ago

That PR is fine against master, since it just touches .gyp files, and the only changes in develop are in the JS code, so there are no conflicts.

farfromrefug commented 7 years ago

@jasongin i switched to your develop branch to make sure we are using the same code. Now it still does not build, same error. I even switched to 15052 too. Now something i find weird is that i don't have a Windows.Devices.Bluetooth folder in my sdk References folder. Do you have one?

jasongin commented 7 years ago

Are you using build.cmd or npm install to build?

All the WinRT types are referenced via %ProgramFiles(x86)%\Windows Kits\10\UnionMetadata\%WIN_SDK_VER%\Windows.winmd. (You can open that file in VS Object Browser to see what types are in it.) Each binding.gyp file references that Windows.winmd via AdditionalUsingDirectories.

The develop and master branches are identical at the moment so it doesn't matter which you use.

farfromrefug commented 7 years ago

@jasongin i was using npm install. I tried build.cmd and still no luck. BTW i only have C++ build tools, no VS IDE. So i can't try the object browser. Do you think it might be an issue? I reall don't see what's going on. Still trying to figure it out...

jasongin commented 7 years ago

I don't think you should need the VS IDE, as long as you have the C++ build tools and the Windows SDK. But I haven't tried that configuration.

Can you collect a verbose msbuild log and put it on a gist? Then maybe I can figure out what's wrong. Something like these commands should do it:

cd build\uwp\windows.devices.bluetooth
"%ProgramFiles(x86)\MSBuild\14.0\Bin\MSBuild.exe" binding.vcxproj /p:Configuration=Release /p:Platform=x64 /v:diag > build.log

Note the binding.vcxproj is generated by node-gyp, so you must have at least attempted building that way first. If you get an error about nan.h not found, you might have to do a npm install in the uwp\windows.devices.bluetooth directory first.

qdot commented 7 years ago

I'm having the same problem. Using VS2015 with 15063 SDK. Updated common.gypi file, but still getting build errors

Here's a gist of stderr/stdout logs when running build.cmd: https://gist.github.com/qdot/eb1c729b04f82f069899115f92ed6555

jasongin commented 7 years ago

@qdot The reason I asked for a verbose MSBuild log above is that would hopefully show exactly which .winmd files are referenced during the build and how. The regular node-gyp output doesn't include that information, so I can't see what is wrong from that.

qdot commented 7 years ago

Ah, sorry about that. Here's the requested log using the msbuild command line specified above.

https://gist.github.com/qdot/a8c2d294c8c6cd546082b239d18005dc

jasongin commented 7 years ago

Thanks. I'm not sure, but I think the problem might be because the VC AdditionalUsingDirectories also includes %ProgramFiles(x86)%\Windows Kits\10\UnionMetadata (without the version subdirectory), and that directory also contains a Windows.winmd file; I don't know what SDK version that one is or is supposed to be, but if it doesn't have the required types then it could be the problem.

I just pushed a change https://github.com/jasongin/noble-uwp/commit/2d9a7b0a9bef8b1091855c107142fbfe1acf7f9a to the develop branch that further simplifies the .gyp files and eliminates that unnecessary directory reference. Can you see if that fixes the build for you?

qdot commented 7 years ago

Pulled changes, moved to develop branch, and changed SDK version to 15063 in the common.gypi, and everything builds now! Thanks!

jasongin commented 7 years ago

Yeah, I should update the version to 15063, since that is (I think) the release build of the Creators Update SDK.

qdot commented 7 years ago

Yup, it is. You can get the creators update and the SDK manually at the moment, without being on the insider program now. That's how I got both of them, just wanted to get a bit of a jump on things before Tuesday. :)

farfromrefug commented 7 years ago

@jasongin amazing! builds perfectly now. I already integrated it in my app. Now i am getting into it. Will create different issues.