natsuk4ze / gal

How to Save Image or Video to Photo Gallery in Flutter
https://pub.dev/packages/gal
BSD 3-Clause "New" or "Revised" License
105 stars 16 forks source link

Can't compile for windows in lower than C++ 20 #189

Closed khoadng closed 9 months ago

khoadng commented 9 months ago

Did you check the documentation and it did not help?

Overview

I'm using Visual Studio Community 2022 17.8.3 with MSVC v143. Additionally, is there a particular reason for adopting C++20? It could potentially limit the package's usability due to compatibility issues.

Steps to reproduce

Just run the sample

Code sample

Code sample ```dart void main() async { WidgetsFlutterBinding.ensureInitialized(); } ```

Environment

Logs ```console [√] Flutter (Channel stable, 3.16.3, on Microsoft Windows [Version 10.0.19045.3803], locale en-US) • Flutter version 3.16.3 on channel stable at V:\Env\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision b0366e0a3f (2 weeks ago), 2023-12-05 19:46:39 -0800 • Engine revision 54a7145303 • Dart version 3.2.3 • DevTools version 2.28.4 [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at C:\Users\Admin\AppData\Local\Android\sdk • Platform android-33, build-tools 30.0.3 • Java binary at: V:\JetBrains\apps\AndroidStudio\ch-0\222.4459.24.2221.10121639\jbr\bin\java • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694) • All Android licenses accepted. [√] Chrome - develop for the web • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe [√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.8.3) • Visual Studio at V:\02_Apps\Microsoft Visual Studio • Visual Studio Community 2022 version 17.8.34330.188 • Windows 10 SDK version 10.0.19041.0 [√] Android Studio (version 2021.3) • Android Studio at V:\JetBrains\apps\AndroidStudio\ch-0\213.7172.25.2113.9014738 • Flutter plugin version 68.1.2 • Dart plugin version 212.5744 • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866) [!] Android Studio (version unknown) • Android Studio at V:\JetBrains\apps\AndroidStudio\ch-0\222.4459.24.2221.10121639 • Flutter plugin version 68.1.2 • Dart plugin version 212.5744 X Unable to determine Android Studio version. • android-studio-dir = V:\JetBrains\apps\AndroidStudio\ch-0\222.4459.24.2221.10121639 • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694) [√] IntelliJ IDEA Ultimate Edition (version 2022.1) • IntelliJ at V:\JetBrains\apps\IDEA-U\ch-0\221.5080.210 • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart [√] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19045.3803] • Chrome (web) • chrome • web-javascript • Google Chrome 120.0.6099.71 • Edge (web) • edge • web-javascript • Microsoft Edge 120.0.2210.77 [√] Network resources • All expected network resources are available. ```

Logs

Logs ```console CMake Deprecation Warning at V:/01_Work/Projects/myproject/build/windows/x64/extracted/firebase_cpp_sdk_windows/CMakeLists.txt:17 (cmake_minimum_required): Compatibility with CMake < 3.5 will be removed from a future version of CMake. Update the VERSION argument value or use a ... suffix to tell CMake that the project does not need compatibility with older versions. 2 Nuget.exe not found, trying to download or use cached version. Nuget.exe not found, trying to download or use cached version. C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\cppwinrt\winrt\impl\Windows.Foundation.0.h(983,26): error C2039: 'wait_for': is not a member of 'winrt::impl' [V:\01_Work\Projects\myproject\build\windows\x64\plugins\gal\gal_plugin.vcxproj] C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\cppwinrt\winrt\impl\Windows.Foundation.0.h(1004,26): error C2039: 'wait_for': is not a member of 'winrt::impl' [V:\01_Work\Projects\myproject\build\windows\x64\plugins\gal\gal_plugin.vcxproj] C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\cppwinrt\winrt\impl\Windows.Foundation.0.h(1038,26): error C2039: 'wait_for': is not a member of 'winrt::impl' [V:\01_Work\Projects\myproject\build\windows\x64\plugins\gal\gal_plugin.vcxproj] C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\cppwinrt\winrt\impl\Windows.Foundation.0.h(1057,26): error C2039: 'wait_for': is not a member of 'winrt::impl' [V:\01_Work\Projects\myproject\build\windows\x64\plugins\gal\gal_plugin.vcxproj] Exception: Build process failed. Exited (1). ```
natsuk4ze commented 9 months ago

HI @khoadng

The gal c++ code uses the co_await keyword, which was standardized from C++20. So basically, this code will only work with C++20 or higher.

However, there may have been co_await already in WinRT, but my memory is not clear on this.

PR is always welcome 😊

khoadng commented 9 months ago

I would love to but my C++ skills are terrible haha Anyway, managed to make it work by downloading a newer Windows SDK, my current version is 10.0.19041.0. Here are the steps: 1) Open Visual Studio Installer 2) Select Mofify 3) Select Windows 10 SDK (10.0.20348.0)

natsuk4ze commented 9 months ago

OK. I will add that to the readme.

I am now a one-person operation, managing Dart, Java, C++, and Swift code, so it is important to squeeze in backward compatibility to ease the burden. Please understand 🙏

natsuk4ze commented 9 months ago

If there is nothing else, I will close this issue.

khoadng commented 9 months ago

Sure you can close it.