webview: Example won't compile on windows after latest updates
What OS are you using (uname -a, or Windows version)?
Windows 11 21H2 Build 22000.739
What programming language are you using (C/C++/Go/Rust)?
go version go1.18.3 windows/amd64 gcc (tdm64-1) 10.3.0 vscode 1.68.1
What did you expect to see and what you saw instead?
I expected the example basic.go to pop up a windows.
Instead I have compile errors that say: cannot use webview.HintNone (constant unknown with invalid type) as webview.Hint value in argument to w.SetSize could not import C (cgo preprocessing failed) (compile)
I cannot figure out if this is a Go bug, vscode bug, or gcc. But I swear it all used to work fine until the latest updates.
package main
import "github.com/webview/webview"
func main() {
w := webview.New(false)
defer w.Destroy()
w.SetTitle("Basic Example")
w.SetSize(480, 320, webview.HintNone)
w.SetHtml("Thanks for using webview!")
w.Run()
}
If I compile on the command line I get…
C:\Users\username\Development\Golang\example>go build
# github.com/webview/webview
In file included from webview.cc:1:
webview.h:839:10: fatal error: WebView2.h: No such file or directory
839 | #include "WebView2.h"
| ^~~~~~~~~~~~
compilation terminated.
I’m pretty sure it has more to do with Go and cgo. But I’m hoping someone here would have figured it out first.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15
Okay. I guess that explains the change. I will try another compiler. Thanks again.
Yes, in Command Prompt example compiled fine. Thanks.
I’ve copied the exact commands from the readme, pasted them into a new batch script named
build.bat, ran the script and the Go example program compiled and ran just fine on my end.Please see if you missed anything here and if so then I would love to know how you came to miss those steps and how the readme can be improved so that those steps are not missed again by anyone else.
I’m unable to reproduce this issue as described on Windows 11 21H2.
I installed MinGW-w64 from WinLibs and latest version of Go.
Are you by any chance running the commands using PowerShell? If that’s the case then please try the good old Command Prompt.