jnschulze / flutter-webview-windows

A WebView2-powered Flutter WebView implementation for the Windows platform.
BSD 3-Clause "New" or "Revised" License
203 stars 120 forks source link

Build Error #239

Closed jayaganeshk closed 1 year ago

jayaganeshk commented 1 year ago

While Running facing below error. Flutter verion: 3.7.5 Visual Studio: 2022

[ +685 ms] std.ixx.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void (__cdecl* std::_Raise_handler)(class
stdext::exception const &)" (__imp_?_Raise_handler@std@@3P6AXAEBVexception@stdext@@@ZEA::<!std>) referenced in function "public: void    
__cdecl stdext::exception::_Raise(void)const " (?_Raise@exception@stdext@@QEBAXXZ::<!std>)
[C:\Users\Administrator\Documents\codecommit\url_host\build\windows\plugins\webview_windows\webview_windows_plugin.vcxproj]
riccardo-lomazzi commented 1 year ago

I have this problem too.

jayaganeshk commented 1 year ago

i downgraded the version to 0.2.1. Seems to be working fine on 0.2.1 version. @riccardo-lomazzi

Darkmessage commented 1 year ago

This seems to be a Visual Studio problem. I built my app and it worked. Changed nothing but upgraded Visual Studio to 17.6 and I got this error. Also VS 17.6.1 and the 17.7 preview had this error.

As you said, downgrading this package to 0.2.1 worked.

So somehow 0.2.2 and VS 17.6 don't go along. (I don't know what VS version I had prior to 17.6, so can't really say which version worked.)

riccardo-lomazzi commented 1 year ago

Downgrading works in Debug, but not in Release.

fatal error C1083: Cannot open include file: 'wil/com.h': No such file or directory [D:\Apps\exampleapp\build\windows\plugins\webview_windows\webview_windows_plugin.vcxproj]

riccardo-lomazzi commented 1 year ago

Downgrading works in Debug, but not in Release.

fatal error C1083: Cannot open include file: 'wil/com.h': No such file or directory [D:\Apps\exampleapp\build\windows\plugins\webview_windows\webview_windows_plugin.vcxproj]

I've managed to make it work. Here's what I did. The problem lies in the fact that the wil library (Windows Implementation Library) is missing from the plugin compilation, for some reason. You cannot add it to the built plugin project, as it deleted and recompiled everytime. As you may know, the plugin's Additional Include Directories also look inside the project's windows/flutter/ephemeral folder, which is deleted after every flutter clean. My solution was to modify the CMakeLists.txt file to copy the library in the ephemeral folder at every build.

So,

  1. Download Windows Implementation Library by nuget (link)
  2. Install it with Visual Studio, and go to the %userprofile%/.nuget/packages/microsoft.windows.implementationlibrary/1.0.220914.1/include folder.
  3. Copy the wil folder inside the project's windows/runner/resources/
  4. Edit the windows/flutter/CMakeLists.txt by inserting the following lines.
    
    # TODO: Move the rest of this into files in ephemeral. See
    # https://github.com/flutter/flutter/issues/57146.
    set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")

INSERT THIS LINE HERE

file(COPY "${PROJECT_DIR}/windows/runner/resources/wil" DESTINATION "${EPHEMERAL_DIR}/")

=== Flutter Library ===

set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")



Hope it helps until the `0.2.2` version will work with a future VS2022 release.
hyUrbanManager commented 1 year ago

While Running facing below error. Flutter verion: 3.7.5 Visual Studio: 2022

[ +685 ms] std.ixx.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void (__cdecl* std::_Raise_handler)(class
stdext::exception const &)" (__imp_?_Raise_handler@std@@3P6AXAEBVexception@stdext@@@ZEA::<!std>) referenced in function "public: void    
__cdecl stdext::exception::_Raise(void)const " (?_Raise@exception@stdext@@QEBAXXZ::<!std>)
[C:\Users\Administrator\Documents\codecommit\url_host\build\windows\plugins\webview_windows\webview_windows_plugin.vcxproj]

version 0.2.2, change file CMakeLists.txt, line 77, target_compile_features(${PLUGIN_NAME} PUBLIC cxx_std_23) to target_compile_features(${PLUGIN_NAME} PUBLIC cxx_std_20) can solve this problem

mustafal commented 1 year ago

While Running facing below error. Flutter verion: 3.7.5 Visual Studio: 2022

[ +685 ms] std.ixx.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void (__cdecl* std::_Raise_handler)(class
stdext::exception const &)" (__imp_?_Raise_handler@std@@3P6AXAEBVexception@stdext@@@ZEA::<!std>) referenced in function "public: void    
__cdecl stdext::exception::_Raise(void)const " (?_Raise@exception@stdext@@QEBAXXZ::<!std>)
[C:\Users\Administrator\Documents\codecommit\url_host\build\windows\plugins\webview_windows\webview_windows_plugin.vcxproj]

version 0.2.2, change file CMakeLists.txt, line 77, target_compile_features(${PLUGIN_NAME} PUBLIC cxx_std_23) to target_compile_features(${PLUGIN_NAME} PUBLIC cxx_std_20) can solve this problem

This worked for me... Thanks a lot

schmitzli commented 1 year ago

VS 17.5.3 is a version where this was still working, but it might be caused by a bug fixed ;-)

dev-ravan commented 1 year ago

When encountering the given error while running, with Flutter version 3.7.5 and Visual Studio 2022, modifying line 77 in the CMakeLists.txt file of version 0.2.2 can resolve the issue. Specifically, changing "target_compile_features(${PLUGIN_NAME} PUBLIC cxx_std_23)" to "target_compile_features(${PLUGIN_NAME} PUBLIC cxx_std_20)" provides a successful solution.

zoenie123 commented 1 year ago

I cannot find that particular CMakeLists.txt file, where is it located?

hiepvip99 commented 1 year ago

Tôi không thể tìm thấy tệp cụ thể CMakeLists.txt đó, nó nằm ở đâu?

you search in C:\Users\Admin\AppData\Local\Pub\Cache\hosted\pub.dev\webview_windows-0.2.2\windows

hyUrbanManager commented 1 year ago

https://github.com/jnschulze/flutter-webview-windows/blob/main/windows/CMakeLists.txt

zoenie123 commented 1 year ago

Ok, that worked for me. When can we expect an update to the plugin?