MixinNetwork / flutter-plugins

🧱 Flutter plugins used in Mixin Messenger.
MIT License
443 stars 192 forks source link

[win_toast] 更新最新代码后,win_toast编译失败 #185

Open chifandeyu opened 1 year ago

chifandeyu commented 1 year ago
已启动重新生成…
1>------ 已启动全部重新生成: 项目: ZERO_CHECK, 配置: Debug x64 ------
1>Checking Build System
2>------ 已启动全部重新生成: 项目: flutter_assemble, 配置: Debug x64 ------
2>Generating E:/githubcode/flutter-plugins/packages/win_toast/example/windows/flutter/ephemeral/flutter_windows.dll, E:/githubcode/flutter-plugins/packages/win_toast/example/windows/flutter/ephemeral/flutter_export.h, E:/githubcode/flutter-plugins/packages/win_toast/example/windows/flutter/ephemeral/flutter_windows.h, E:/githubcode/flutter-plugins/packages/win_toast/example/windows/flutter/ephemeral/flutter_messenger.h, E:/githubcode/flutter-plugins/packages/win_toast/example/windows/flutter/ephemeral/flutter_plugin_registrar.h, E:/githubcode/flutter-plugins/packages/win_toast/example/windows/flutter/ephemeral/flutter_texture_registrar.h, E:/githubcode/flutter-plugins/packages/win_toast/example/windows/flutter/ephemeral/cpp_client_wrapper/core_implementations.cc, E:/githubcode/flutter-plugins/packages/win_toast/example/windows/flutter/ephemeral/cpp_client_wrapper/standard_codec.cc, E:/githubcode/flutter-plugins/packages/win_toast/example/windows/flutter/ephemeral/cpp_client_wrapper/plugin_registrar.cc, E:/githubcode/flutter-plugins/packages/win_toast/example/windows/flutter/ephemeral/cpp_client_wrapper/flutter_engine.cc, E:/githubcode/flutter-plugins/packages/win_toast/example/windows/flutter/ephemeral/cpp_client_wrapper/flutter_view_controller.cc, _phony_
2>Building Custom Rule E:/githubcode/flutter-plugins/packages/win_toast/example/windows/flutter/CMakeLists.txt
3>------ 已启动全部重新生成: 项目: flutter_wrapper_plugin, 配置: Debug x64 ------
3>Building Custom Rule E:/githubcode/flutter-plugins/packages/win_toast/example/windows/flutter/CMakeLists.txt
3>core_implementations.cc
3>standard_codec.cc
3>plugin_registrar.cc
3>正在生成代码...
3>flutter_wrapper_plugin.vcxproj -> E:\githubcode\flutter-plugins\packages\win_toast\example\build\windows\flutter\Debug\flutter_wrapper_plugin.lib
4>------ 已启动全部重新生成: 项目: win_toast_plugin, 配置: Debug x64 ------
4>Building Custom Rule E:/githubcode/flutter-plugins/packages/win_toast/example/windows/flutter/ephemeral/.plugin_symlinks/win_toast/windows/CMakeLists.txt
4>win_toast_plugin.cpp
4>DesktopNotificationManagerCompat.cpp
4>notification_manager.cc
4>dll_importer.cc
4>正在生成代码...
4>  正在创建库 E:/githubcode/flutter-plugins/packages/win_toast/example/build/windows/plugins/win_toast/Debug/win_toast_plugin.lib 和对象 E:/githubcode/flutter-plugins/packages/win_toast/example/build/windows/plugins/win_toast/Debug/win_toast_plugin.exp
4>win_toast_plugin.obj : error LNK2019: 无法解析的外部符号 WINRT_GetRestrictedErrorInfo,函数 "public: __cdecl winrt::hresult_error::hresult_error(struct winrt::hresult,struct winrt::take_ownership_from_abi_t)" (??0hresult_error@winrt@@QEAA@Uhresult@1@Utake_ownership_from_abi_t@1@@Z) 中引用了该符号
4>DesktopNotificationManagerCompat.obj : error LNK2001: 无法解析的外部符号 WINRT_GetRestrictedErrorInfo
4>win_toast_plugin.obj : error LNK2019: 无法解析的外部符号 WINRT_RoGetActivationFactory,函数 "struct winrt::Windows::Foundation::IActivationFactory __cdecl winrt::get_activation_factory<struct winrt::Windows::Foundation::IActivationFactory>(struct winrt::param::hstring const &)" (??$get_activation_factory@UIActivationFactory@Foundation@Windows@winrt@@@winrt@@YA?AUIActivationFactory@Foundation@Windows@0@AEBUhstring@param@0@@Z) 中引用了该符号
4>DesktopNotificationManagerCompat.obj : error LNK2001: 无法解析的外部符号 WINRT_RoGetActivationFactory
4>win_toast_plugin.obj : error LNK2019: 无法解析的外部符号 WINRT_RoOriginateLanguageException,函数 "private: void __cdecl winrt::hresult_error::originate(struct winrt::hresult,void *)" (?originate@hresult_error@winrt@@AEAAXUhresult@2@PEAX@Z) 中引用了该符号
4>DesktopNotificationManagerCompat.obj : error LNK2001: 无法解析的外部符号 WINRT_RoOriginateLanguageException
4>win_toast_plugin.obj : error LNK2019: 无法解析的外部符号 WINRT_SetRestrictedErrorInfo,函数 "public: struct winrt::hresult __cdecl winrt::hresult_error::to_abi(void)const " (?to_abi@hresult_error@winrt@@QEBA?AUhresult@2@XZ) 中引用了该符号
4>win_toast_plugin.obj : error LNK2019: 无法解析的外部符号 WINRT_WindowsCreateString,函数 "void * __cdecl winrt::impl::create_string(wchar_t const *,unsigned int)" (?create_string@impl@winrt@@YAPEAXPEB_WI@Z) 中引用了该符号
4>DesktopNotificationManagerCompat.obj : error LNK2001: 无法解析的外部符号 WINRT_WindowsCreateString
4>win_toast_plugin.obj : error LNK2019: 无法解析的外部符号 WINRT_WindowsCreateStringReference,函数 "public: __cdecl winrt::param::hstring::hstring(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &)" (??0hstring@param@winrt@@QEAA@AEBV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@Z) 中引用了该符号
4>DesktopNotificationManagerCompat.obj : error LNK2001: 无法解析的外部符号 WINRT_WindowsCreateStringReference
4>win_toast_plugin.obj : error LNK2019: 无法解析的外部符号 WINRT_WindowsDeleteString,函数 "public: static void __cdecl winrt::impl::hstring_traits::close(void *)" (?close@hstring_traits@impl@winrt@@SAXPEAX@Z) 中引用了该符号
4>DesktopNotificationManagerCompat.obj : error LNK2001: 无法解析的外部符号 WINRT_WindowsDeleteString
4>win_toast_plugin.obj : error LNK2019: 无法解析的外部符号 WINRT_WindowsPreallocateStringBuffer,函数 "public: __cdecl winrt::impl::hstring_builder::hstring_builder(unsigned int)" (??0hstring_builder@impl@winrt@@QEAA@I@Z) 中引用了该符号
4>win_toast_plugin.obj : error LNK2019: 无法解析的外部符号 WINRT_WindowsDeleteStringBuffer,函数 "public: __cdecl winrt::impl::hstring_builder::~hstring_builder(void)" (??1hstring_builder@impl@winrt@@QEAA@XZ) 中引用了该符号
4>win_toast_plugin.obj : error LNK2019: 无法解析的外部符号 WINRT_WindowsPromoteStringBuffer,函数 "public: struct winrt::hstring __cdecl winrt::impl::hstring_builder::to_hstring(void)" (?to_hstring@hstring_builder@impl@winrt@@QEAA?AUhstring@3@XZ) 中引用了该符号
4>win_toast_plugin.obj : error LNK2019: 无法解析的外部符号 WINRT_WindowsGetStringRawBuffer,函数 "public: wchar_t const * __cdecl winrt::hstring::begin(void)const " (?begin@hstring@winrt@@QEBAPEB_WXZ) 中引用了该符号
4>DesktopNotificationManagerCompat.obj : error LNK2001: 无法解析的外部符号 WINRT_WindowsGetStringRawBuffer
4>E:\githubcode\flutter-plugins\packages\win_toast\example\build\windows\plugins\win_toast\Debug\win_toast_plugin.dll : fatal error LNK1120: 11 个无法解析的外部命令
boyan01 commented 1 year ago
  1. What is the system version? win11?
  2. Is it works fine if you build with flutter command? cd example && flutter run -d windows
chifandeyu commented 1 year ago
  1. What is the system version? win11?
  2. Is it works fine if you build with flutter command? cd example && flutter run -d windows

flutter clean flutter run -d windows 执行后就是报了上面的错误。

flutter doctor:

[✓] Flutter (Channel stable, 3.3.8, on Microsoft Windows [版本 10.0.19044.2006], locale zh-CN)
    • Flutter version 3.3.8 on channel stable at D:\DevTools\flutter3.3.8_custom\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 52b3dc25f6 (6 weeks ago), 2022-11-09 12:09:26 +0800
    • Engine revision 857bd6b74c
    • Dart version 2.18.4
    • DevTools version 2.15.0

[!] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at C:\Users\yuchang.xu\AppData\Local\Android\sdk
    • Platform android-33, build-tools 32.0.0
    ✗ Android SDK file not found: C:\Users\yuchang.xu\AppData\Local\Android\sdk\build-tools\32.0.0\aapt.
    • Try re-installing or updating your Android SDK,
      visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions.

[✓] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.7)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
    • Visual Studio Community 2019 version 16.11.31911.196
    • Windows 10 SDK version 10.0.19041.0

[✓] Android Studio (version 2020.3)
    • Android Studio at D:\Program Files\Android\Android Studio
    • 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
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] VS Code (version 1.74.1)
    • VS Code at C:\Users\yuchang.xu\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.44.0

[✓] Connected device (1 available)
    • Windows (desktop) • windows • windows-x64 • Microsoft Windows [版本 10.0.19044.2006]

[✓] HTTP Host Availability
    • All required HTTP hosts are available

image

boyan01 commented 1 year ago

Fine, I know very little about Windows development ,so may have to wait for someone else to answer the reason.

But this project with new win_toast plugin was build successful on GitHub Actions. https://github.com/MixinNetwork/flutter-app/actions/runs/3657044403/jobs/6180183222

ekokurniadi commented 1 year ago

Hello, any updates for this issues ? i got same issues

ekokurniadi commented 1 year ago

Hi, i just solved the issue after add some code on CMakeList on this package @chifandeyu

cmake_minimum_required(VERSION 3.14)
set(PROJECT_NAME "win_toast")
project(${PROJECT_NAME} LANGUAGES CXX)

# This value is used when generating builds using this plugin, so it must
# not be changed
set(PLUGIN_NAME "win_toast_plugin")

# Find Nuget First
find_program(NUGET_EXE NAMES nuget)
if(NOT NUGET_EXE)
    message("NUGET.EXE not found.")
    message(FATAL_ERROR "Please install this executable, and run CMake again.")
endif()

# Install WinRT using Nuget
exec_program(${NUGET_EXE}
    ARGS install "Microsoft.Windows.CppWinRT" -Version 2.0.221121.5 -ExcludeVersion -OutputDirectory ${CMAKE_BINARY_DIR}/packages)

add_library(${PLUGIN_NAME} SHARED
  win_toast_plugin.cpp
  pch.h
  DesktopNotificationManagerCompat.h
  DesktopNotificationManagerCompat.cpp
  notification_manager.h
  notification_manager.cc
  dll_importer.cc
  dll_importer.h
  )

apply_standard_settings(${PLUGIN_NAME})
set_target_properties(${PLUGIN_NAME} PROPERTIES
  CXX_VISIBILITY_PRESET hidden)
set_target_properties(${PLUGIN_NAME} PROPERTIES

# add VS Project Import
VS_PROJECT_IMPORT ${CMAKE_BINARY_DIR}/packages/Microsoft.Windows.CppWinRT/build/native/Microsoft.Windows.CppWinRT.props
)
# Link the WinRT Lib
target_link_libraries(${PLUGIN_NAME} PRIVATE ${CMAKE_BINARY_DIR}/packages/Microsoft.Windows.CppWinRT/build/native/Microsoft.Windows.CppWinRT.targets)

target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
target_include_directories(${PLUGIN_NAME} INTERFACE
  "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin)

# List of absolute paths to libraries that should be bundled with the plugin
set(win_toast_bundled_libraries
  ""
  PARENT_SCOPE
  )
GaelHuyghe commented 1 year ago

Hello everyone,

Just installed the plugin and I have the exact same issue And the fix provided by @ekokurniadi does work

Is it possible to integrate it in the plugin directly ?