jni-bind compatible with Visual Studio 2019 - 16.11.40? #384
-
|
I am trying to setup the environment on a Windows 10 machine, using Visual Studio 2019 with compilation flags: I am including jni_bind_release.h and get a bunch of compilation errors: Any idea on what I am doing wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 23 comments 27 replies
-
|
I'm afraid not, and, this might sound ridiculous but I actually really struggle to get a Windows environment up and running. I don't work with VSCode so it's an extra lift for me to get it running. You're not doing anything wrong, it's likely a compiler incompatability. That said, these types of compatibility issues when bringing up a new compiler are common. If you could provide me a Godbolt sample I can look at, preferably with as little code as possible, I'd be happy to take a look. If you/we can make it work, I'd love to fold this into JNI Bind and add an MSVC compilation test. That said, my time is somewhat more limited and I need some help if folks want this. This issue was tracked, but I unfortunately gave up due to lack of time/resources: |
Beta Was this translation helpful? Give feedback.
-
|
Ah, hmmn, actually the first part of the bug stands out: I think this might be the same as #198. Basically, jint is a different type on Windows I think. If so I think I can probably fix it but it would help to have a way to repro this, which I'm not 100% sure how to do. |
Beta Was this translation helpful? Give feedback.
-
|
I think this is what he did: "If I take a big hammer and make the typedef to a C int on Windows, all is well with jni-bind. // 'long' is always 32 bit on windows so this matches what jdk expects Obviously that isn't suitable for JNI Bind. I think what actually needs to happen is just a simple change in the proxy system but I need a mechanism to exercise it which I could never duplicate. If you're able to create a pull request I can exercise it if you just propose it. We can work on merging pull requests later if we manage to get there, it's actually never come up before as all submissions have originated from Google (and mostly from me). I think if you try the author's "big hammer" you should be able to at least try JNI Bind (beyond the Godbolt sample). To truly fix it, I think you need to modify here. I think there also needs to be an Your simplest bet is to build with Bazel (modifying the monolith header will be hard). I can give it a quick try if that doesn't work but it's hard given I can't validate the failure. I guess an alternative way you could help would be to make a PR to add a Windows test runner so I can see failure. |
Beta Was this translation helpful? Give feedback.
-
|
Curious if you made any progress? Let me know if I can provide support. |
Beta Was this translation helpful? Give feedback.
-
|
You're fine, take your time! There's interest on it being completed based on the web traffic, but I am not on any particular deadline for anything. I'm just glad to have some help. |
Beta Was this translation helpful? Give feedback.
-
|
I'm seeing the following in your log: To me that sounds like something is way off, like you don't have the standard library. I'm not sure how you could be missing that include unless you had a pre C++17 compiler (string_view was first in 17). I also see If your flags weren't being communicated to Bazel properly I can imagine it might default to a really old C++ version. Happy to communicate through a branch when I have something to share, that sounds like a good idea. |
Beta Was this translation helpful? Give feedback.
-
|
Bummer, if Visual Studio doesn't allow Bazel to build with C++20 then it won't do very much at all. I put together a branch which is pure AI slop to build with CMake: #395 It has other unrelated parent commits you will need to tease out. I have no idea if it compiles, I was just experimenting with AI tools. Apologies this is all so hard, build systems always seem that way :( If you can come up with a way to make GitHub actions trigger the failure that would also be good. |
Beta Was this translation helpful? Give feedback.
-
|
That'd be awesome! Feel free to snag #240 |
Beta Was this translation helpful? Give feedback.
-
|
Sure! You're the first outside contributor so bear with me if it takes a bit. Shot you an invite for write access. |
Beta Was this translation helpful? Give feedback.
-
|
Awesome! I will need some time on my end to figure out how to merge this upstream in google3. I'll try to get back to you soon on the compilation failure, but it looks familiar which is a good sign. Specifically, This is almost certainly the issue. I recall a differently sized jint on MSVC was the root cause of the issue. |
Beta Was this translation helpful? Give feedback.
-
|
Sorry, I haven't had time to look at this, but I imagine this can be replicated by forcing jint to a different size on Linux (so I can test). I imagine this can be fixed by adding a separate definition in proxy_definitions.h 's primitive proxy defintion. |
Beta Was this translation helpful? Give feedback.
-
|
Alright, finally had time to take a look. I posted #398 but don't have a way to test it. It's rebased on top of your cmake so you should be able to try it out of the box. If you feel so inclined you're welcome to setup a github action for CMake + Windows and I can validate my own work. Please let me know how it goes! |
Beta Was this translation helpful? Give feedback.
-
|
This is phenomenal, it will help me a lot. I checked out your output failure and I believe it makes sense, it's complaining that jint and int aren't the same size which is the same failure. I will take a look at it and get back to you. |
Beta Was this translation helpful? Give feedback.
-
|
I tried to adopt your github action except I folded it into the main set of workflows. It didn't work as intended, complaining about a missing visual studio. Do you see anything I could have done wrong here: https://github.com/google/jni-bind/actions/runs/14160602391/job/39665494437?pr=400 (#400). Edit: Never mind, I see now you had 2019 as the windows vs. not latest. I can do that, although, is there any good reason for it? |
Beta Was this translation helpful? Give feedback.
-
|
Okay, I've made some progress on https://github.com/google/jni-bind/actions/runs/14163177478/job/39671863750?pr=401 #401 . It's failing on an error that makes no sense to me and I can't really dig into. It also looks like it's struggling with tests in Beyond that I think there are other real failures (that I don't understand). Could I ask you to take a pass and see if the errors could be a cmake issue? |
Beta Was this translation helpful? Give feedback.
-
|
🤦🏻♂️ I see now. I updated it but looks like I'm now having other unrelated cmake issues... I took off a trailing newline you added from the version file but I'm not sure if it's causing issues. Looks like it is. I'll have to take a look. |
Beta Was this translation helpful? Give feedback.
-
|
Yes, unfortunately GitHub was failing because I added Windows, but then I guess for an unrelated reason, was failing to queue other presubmits. This meant HEAD was failing and I couldn't figure out why, so I was progressively reverting as much as I could until it compiled. I'm going to add it back now, sorry, this has been a slog, it's very slow to test. |
Beta Was this translation helpful? Give feedback.
-
|
So, I've isolated at least one failure that needs to be fixed: https://github.com/google/jni-bind/actions/runs/14225648537/job/39864436223?pr=401 It looks like the pack discriminated forward is being treated differently by MSVC than it is on clang, although I'm not sure why. This will require more digging. For now I I'm running next_test only but it shows the behaviour fairly clearly. |
Beta Was this translation helpful? Give feedback.
-
|
Sorry, it's unbelievably slow to try to fix this via presubmit tests. I tried to get a Windows distro up and running so I could try Cmake but I'm bizarrely unable to get there because of corp reasons. I don't have a personal Windows license so it might be a while. |
Beta Was this translation helpful? Give feedback.
-
|
That's what I was doing, but trying to go one by one is quite slow. I comissioned a Windows machine I could connect into on my personal machine so we'll see how that goes. Enjoy your holiday! |
Beta Was this translation helpful? Give feedback.
-
|
(Feel free to add me on LinkedIn btw, you've been very helpful!) |
Beta Was this translation helpful? Give feedback.
-
|
For posterity, the installer for msvc 2019 build tools are here https://learn.microsoft.com/en-us/visualstudio/releases/2019/history#release-dates-and-build-numbers |
Beta Was this translation helpful? Give feedback.
-
|
And JDK here: https://www.oracle.com/java/technologies/downloads/#jdk24-windows |
Beta Was this translation helpful? Give feedback.
I'm afraid not, and, this might sound ridiculous but I actually really struggle to get a Windows environment up and running. I don't work with VSCode so it's an extra lift for me to get it running. You're not doing anything wrong, it's likely a compiler incompatability.
That said, these types of compatibility issues when bringing up a new compiler are common. If you could provide me a Godbolt sample I can look at, preferably with as little code as possible, I'd be happy to take a look.
If you/we can make it work, I'd love to fold this into JNI Bind and add an MSVC compilation test. That said, my time is somewhat more limited and I need some help if folks want this.
This issue was tracked,…