WebView2: ‘ICoreWebView2Controller2’: undeclared identifier

I updated from JUCE 6.1.2 to 6.1.4 and I’m getting

error C2065: ‘ICoreWebView2Controller2’: undeclared identifier

In my cmake configuration, I have:

target_include_directories(${PLUGIN_TARGET_NAME} PRIVATE "~/Downloads/microsoft.web.webview2.1.0.705.50/build/native/include")

target_compile_definitions(${PLUGIN_TARGET_NAME}
        PRIVATE
        # JUCE_WEB_BROWSER and JUCE_USE_CURL would be on by default, but you might not need them.
        JUCE_WEB_BROWSER=1  # If you remove this, add `NEEDS_WEB_BROWSER TRUE` to the `juce_add_plugin` call
        JUCE_USE_WINRT_WEBVIEW=1
        JUCE_USE_WIN_WEBVIEW2=1
)

Is this a valid CMake configuration? I haven’t seen anyone else

Please note that using the WebView2 with CMake is not currently supported:

I got it working, by manually downloading the package from nuget - and extracting headers/binaries with WinRar.
Looks like the problem I had is the newer version of Juce was referencing a newer version of the webview package - so I downloaded a newer version

Hey there, thanks for the information. I’m currently struggling with that on Windows, I didn’t know about the non-compatibility with CMake and was trying to find a way to get it working, with no success so far :frowning:

@tobiq Can you explain how you managed to get the package and install it please? I don’t find the Webview2.h header to make my project build.

Also when I try to build, I include <juce_gui_extra/juce_gui_extra.h> to use juce::WindowsWebView2WebBrowserComponent but then I get a build error on this file :

[build] S:\Documents\dev\WebPlugin\build\_deps\juce-src\modules\juce_gui_extra/misc/juce_PushNotifications.h(301,13): error: expected identifier
[build]             small,
[build]             ^
[build] C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared\rpcndr.h(190,15): note: expanded from macro 'small'
[build] #define small char

I fix it by renaming small in the enum but I wonder if it’s normal that I get this error, and also if I needed to include the header. My cmake is like that :

target_compile_definitions(${BaseTargetName}
        PUBLIC
        JUCE_WEB_BROWSER=1
        JUCE_USE_WIN_WEBVIEW2=1
        JUCE_USE_CURL=0
        JUCE_VST3_CAN_REPLACE_VST2=0)

target_link_libraries(${BaseTargetName} PRIVATE
        juce::juce_audio_utils
        juce::juce_recommended_config_flags
        juce::juce_recommended_lto_flags
        juce::juce_recommended_warning_flags
        juce::juce_gui_extra)

Any help would be appreciated, thanks a lot :slight_smile:

I searched a bit differently and found this repository on github that does it with CMake : webviewpp/CMakeLists.txt at master · Soundux/webviewpp · GitHub

It requires to get the nuget.exe program from here NuGet Gallery | Downloads and add it to the path but then it works and everything builds fine :slight_smile:

I still have the problem with the code in juce_PushNotifications.h though.

And I have an other issue on my side that I must solve to check if the weview appears correctly in the plugin. I’ll let you know if it works, but it’s already a major improvement for me!

Cheers

Downloaded from here: https://globalcdn.nuget.org/packages/microsoft.web.webview2.1.0.1054.31.nupkg

(by clicking “download package” on this page)

Opened it up with WinRar and found headers/dlls - and included them to cmake project.
There may be a nicer way to use nuget packages with cmake…

Looks like there is: