webview/webview

Error when Compiling WebView Example: Deprecated Function Warning and Runtime Panic

RocketPLN opened this issue · 1 comments

I'm encountering a problem while trying to compile an example from the WebView GitHub repository. When using the following command:

go build -ldflags="-H windowsgui" basic.go

Go version: 1.21
Operating System: Mint 21.2

Error:

In file included from webview.cc:1:
webview.h: In member function ‘void webview::detail::gtk_webkit_engine::eval(const string&)’:
webview.h:617:35: warning: ‘void webkit_web_view_run_javascript(WebKitWebView*, const gchar*, GCancellable*, GAsyncReadyCallback, gpointer)’ is deprecated: Use 'webkit_web_view_evaluate_javascript' instead [-Wdeprecated-declarations]
  617 |     webkit_web_view_run_javascript(WEBKIT_WEB_VIEW(m_webview), js.c_str(),
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  618 |                                    nullptr, nullptr, nullptr);
      |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/webkitgtk-4.0/webkit/WebKitPrintOperation.h:29,
                 from /usr/include/webkitgtk-4.0/webkit2/webkit2.h:72,
                 from webview.h:510,
                 from webview.cc:1:
/usr/include/webkitgtk-4.0/webkit/WebKitWebView.h:526:1: note: declared here
  526 | webkit_web_view_run_javascript                       (WebKitWebView             *web_view,
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# command-line-arguments
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x38 pc=0x5ce645]

goroutine 1 [running]:
cmd/link/internal/ld.(*peSection).emitRelocations(0x0, 0xc0001180e0, 0xc000792790)
        cmd/link/internal/ld/pe.go:406 +0x25
cmd/link/internal/ld.(*peFile).emitRelocations(0x8998c0, 0xc00011e200)
        cmd/link/internal/ld/pe.go:645 +0x4f8
cmd/link/internal/ld.asmbPe(0xc00011e200)
        cmd/link/internal/ld/pe.go:1748 +0x331
cmd/link/internal/ld.asmb2(0xc00011e200?)
        cmd/link/internal/ld/asmb.go:102 +0xac
cmd/link/internal/ld.Main(_, {0x20, 0x20, 0x1, 0x7, 0x10, 0x0, {0xc000012449, 0x1, 0x1}, ...})
        cmd/link/internal/ld/main.go:389 +0x17f7
main.main()
        cmd/link/main.go:72 +0xdfb

Source Code:

package main

import "github.com/webview/webview"

func main() {
	debug := true
	w := webview.New(debug)
	defer w.Destroy()
	w.SetTitle("Basic Example")
	w.SetSize(480, 320, webview.HintNone)
	w.SetHtml("Thanks for using WebView!")
	w.Run()
}

The deprecation warning can be ignored but the error is peculiar.

If I understand this correctly then the Go tooling itself is crashing while it's building the program. To me this looks like an issue with Go tooling so we can't help you with that.

Are you trying to cross-compile from Linux to Windows? If so then the command you provided is insufficient.