-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
win: fix Universal Windows Platform build #1048
Conversation
We use
|
Unfortunately |
Can't we then just pretend that |
3696353
to
1d8b9fc
Compare
@bagder You're right, everything starting from Vista is currently treated the same way (there is code in schannel.c that checks for at least Windows 8.1, but that code cannot be compiled for Thanks for your comments, @jay and @bagder ! I've updated the commit to let Curl_verify_windows_version assume we're always running on the target Windows version for I've tested the code (the only call to this function for Windows "modern" apps is currently from connect.c) in two test apps targeting Windows 8.0 and 10, respectively. |
should this pull request include a change to the MakefileBuild.vc to pass the correct value of _WIN32_WINNT? Currently it ends up defined but empty. That will make this line fail: I notice the automated build uses CMake, and although you can't see the command for compiling files of the library, it certainly defines this explicitly for the tests: Or is CMake the only way the Windows 10 build should be done? If so a note in the winbuild directory? |
Marcel thanks for your changes. I need to catch up with you here though because I'm unfamiliar with this. I can't find anything in MS documentation that says UWP works on less than Windows 10, but they say this:
... and then in the To Paul's point:
CURL_WINDOWS_APP is only supposed to be defined if >= 0x602. However I think this raises an interesting point, if someone wants to build a libcurl DLL that targets Windows RT/UWP then logically they'd have to define CURL_WINDOWS_APP? How exactly does this work? Can that DLL still be used on desktops? |
Yes, exactly.
You mean a DLL that works for classic desktop applications as well as WinRT/UWP apps? I've never tried that, I've always compiled all external libraries for my target platform. How I build libcurl for UWP/WinRT is add an empty UWP/WinRT project to the MSVC14 libcurl solution file, move all files over from the existing project file, and adjust the preprocessor definitions. I don't define |
@joycepg |
My understanding of the WIN32 API availability:
The point is that Windows 10 (UWP) has more WIN32 than Windows 8.x (Windows Runtime), and libcurl will never run on Windows Runtime because socket() is not allowed. So I think CURL_WINDOWS_APP should effectively mean "Windows 10" As far as having a single .lib or .dll that works on both desktop and UWP apps, this is fine, as long as the library only calls the allowed subset of WIN32 for where it is linked to. For example, if I build a "desktop" version of libcurl using nmake with all defaults, then try to link that library into a UWP, it will fail. Conversely, I could build a library using the UWP subset that would also work in a desktop app, but I couldn't use WinSSL or SSPI for example. There is also a new thing in Windows 10 called a Windows Runtime Component, which is also a DLL, but it is a COM object + some metadata. Not relevant to libcurl. |
WinSock is available for both Windows RT 8.1 and Windows Phone 8.1 apps when using the updated Windows 8.1 SDK from Visual Studio 2013 Update 3, and libcurl compiles fine with it: |
bother. I missed that sdk update. |
Unfortunately I haven't managed to reproduce that. With your build instructions from #820 (comment), everything compiles fine for me when run from the VS2015 x64 x86 Cross Tools Command Prompt. If I add
to Curl_verify_windows_version, then I get the expected error: Perhaps there should be an option added to the nmake build to specify the target Windows version, but unfortunately I'm not familiar with nmake. The only thing I've ever built with nmake is OpenSSL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like how this moves the windows app check to the general version check so I'm all for this patch. I would however appreciate getting someone with more windows knowledge to +1 before we merge.
I think there are potential problems if a DLL built for Windows apps is then used in Windows desktops. As far as I can tell that is possible, and there we wouldn't want to guess about the version. |
@jay Sorry, I think I don't quite understand. Are you suggesting to determine at runtime if we're running in a Windows app or desktop application? |
Thanks for your patience, this is what I'm trying to figure out. What I want to handle is a scenario where someone builds a DLL for a Windows app and then runs that DLL on the desktop. In other words can you run a UWP libcurl DLL in Windows 7, even if you can't run your app in Windows 7?. Is that a non-issue? I'm unclear whether or not that could happen since it's only using a subset of the API. I just read 'How to: Use Existing C++ Code in a Universal Windows Platform App' and maybe I missed it but I don't see it said either way. |
@jay Ah, I see, thanks. I don't think that's a big issue as Of course one could manually override it, but that's asking for trouble, especially as many replacements for Windows API functions forbidden in store/phone/universal apps are only available in Windows 8.0 and higher. So the code will most likely either not compile (when setting it too low) or not run (when setting it to Windows 8+ and running it on Windows 7). I'll try if using a UWP DLL/lib in a desktop application even works and report back. |
@jay The Windows 7 desktop application compiles without warnings, but doesn't even start on Windows 10:
0xc000a200 means |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please review push-access-guidelines, you can now commit this on your own. As seen in 'How to work with an issue' basically you will get the latest from upstream/master and then rebase your branch on it, before checking out your local copy of upstream/master (usually named 'master' branch) and then merging in your branch's changes fast-forward only.
Also you will need to edit (git commit --amend) your commit message to associate the PR. Since the request can be closed you can add a line that says 'Closes' or just a ref line and close it manually. Here is what I mean
...
Bug: https://github.com/curl/curl/pull/820#issuecomment-250889878
Reported-by: Paul Joyce
Closes https://github.com/curl/curl/pull/1048
or
...
Bug: https://github.com/curl/curl/pull/820#issuecomment-250889878
Reported-by: Paul Joyce
Ref: https://github.com/curl/curl/pull/1048
1d8b9fc
to
b684d97
Compare
This fixes a merge error in commit 7f3df80 caused by commit 332e8d6. Additionally, this changes Curl_verify_windows_version for Windows App builds to assume to always be running on the target Windows version. There seems to be no way to determine the Windows version from a UWP app. Neither GetVersion(Ex), nor VerifyVersionInfo, nor the Version Helper functions are supported. Bug: curl#820 (comment) Reported-by: Paul Joyce
b684d97
to
2771e92
Compare
@jay Thank you very much for the review and those great guidelines! I hope I did it correctly. |
As reported by @joycepg here: #820 (comment)
This fixes a merge error in commit 7f3df80 caused by commit 332e8d6.
Additionally, this disables Curl_verify_windows_version for Windows App
builds. There seems to be no way to determine the Windows version from
a UWP app. Neither GetVersion(Ex), nor VerifyVersionInfo, nor the
Version Helper functions are supported.