v icon indicating copy to clipboard operation
v copied to clipboard

Error building graphic app (WebView)

Open Ev1lT3rm1nal opened this issue 4 years ago • 2 comments

V doctor:

OS: windows, Microsoft Windows 11 Pro v22000 64-bit
Processor: 12 cpus, 64bit, little endian, Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
CC version: Error: exec failed (CreateProcess) with code 2: El sistema no puede encontrar el archivo especificado.

 cmd: cc --version

getwd: C:\Users\------\Desktop\ui-\examples
vmodules: C:\Users\------\.vmodules
vroot: C:\v
vexe: C:\v\v.exe
vexe mtime: 2021-11-08 17:09:02
is vroot writable: true
is vmodules writable: true
V full version: V 0.2.4 08667c5

Git version: git version 2.32.0.windows.2
Git vroot status: Error: fatal: not a git repository (or any of the parent directories): .git
.git/config present: false
thirdparty/tcc status: thirdparty-windows-amd64 0f5168cd

What did you do? v -g -o vdbg cmd/v && vdbg .\webview.v

import ui
import ui.webview

struct App {
	webview &webview.WebView
}

fn main() {
	mut app := &App{
		webview: voidptr(0)
	}
	window := ui.window(
		width: 800
		height: 100
		state: voidptr(0)
		title: 'V ui.webview demo'
		children: [
			ui.row(
				// stretch: true
				margin: ui.Margin{10, 10, 10, 10}
				height: 100
				children: [
					ui.button(
						text: 'Open'
						width: 70
						height: 100
						onclick: fn (a voidptr, b voidptr) {
							// println("onclick open")
							webview.new_window(
								url: 'https://github.com/revosw/ui/tree/master'
								title: 'hello'
							)
						}
					),
					ui.button(
						text: 'Navigate to google'
						onclick: fn (a voidptr, b voidptr) {
							// println("onclick google")
							// app.webview.navigate("https://google.com")
						}
					),
					ui.button(
						text: 'Navigate to steam'
						onclick: fn (a voidptr, b voidptr) {
							// println("onclick steam")
							// app.webview.navigate("https://steampowered.com")
						}
					),
					ui.button(
						text: 'Rig on_navigate'
						onclick: fn (a voidptr, b voidptr) {
							// println("onclick rig")
							// app.webview.on_navigate(fn (url string) {
							// 	exit(0)
							// })
						}
					),
					ui.button(
						text: 'Run javascript'
						onclick: fn (a voidptr, b voidptr) {
							// println("onclick javascript")
							// app.webview.exec("alert('Ran some javascript')")
						}
					),
				]
			),
		]
	)
	ui.run(window)
}

What did you expect to see?

A webview

What did you see instead?

C:\Users\------\.vmodules\ui\webview\webview.v:5:8: warning: module 'ui' is imported but never used
    3 | module webview
    4 | 
    5 | import ui
      |        ~~
    6 | 
    7 | [heap]
.\webview.v:9:6: warning: unused variable: `app`
    7 | 
    8 | fn main() {
    9 |     mut app := &App{
      |         ~~~
   10 |         webview: voidptr(0)
   11 |     }
==================
tcc: error: file 'Version.lib' not found
...
==================
(Use `v -cg` to print the entire error message)

builder error: 
==================
C error. This should never happen.

This is a compiler bug, please report it using `v bug file.v`.

https://github.com/vlang/v/issues/new/choose

You can also use #help on Discord: https://discord.gg/vlang```

Ev1lT3rm1nal avatar Nov 12 '21 18:11 Ev1lT3rm1nal

The example will have to be updated to current V standards before any further actions can be taken.

JalonSolov avatar Feb 01 '25 02:02 JalonSolov

Does indeed have issues:

module main

import ui
import ui.webview

struct App {
	webview &webview.WebView
}

fn main() {
	mut app := &App{
		webview: voidptr(0)
	}
	window := ui.window(
		width: 800
		height: 100
		title: 'V ui.webview demo'
		children: [
			ui.row(
				// stretch: true
				margin: ui.Margin{10, 10, 10, 10}
				height: 100
				children: [
					ui.button(
						text: 'Open'
						width: 70
						height: 100
						on_click: fn (b &ui.Button) {
							// println("onclick open")
							webview.new_window(
								url: 'https://github.com/revosw/ui/tree/master'
								title: 'hello'
							)
						}
					),
					ui.button(
						text: 'Navigate to google'
						on_click: fn (b &ui.Button) {
							// println("onclick google")
							// app.webview.navigate("https://google.com")
						}
					),
					ui.button(
						text: 'Navigate to steam'
						on_click: fn (b &ui.Button) {
							// println("onclick steam")
							// app.webview.navigate("https://steampowered.com")
						}
					),
					ui.button(
						text: 'Rig on_navigate'
						on_click: fn (b &ui.Button) {
							// println("onclick rig")
							// app.webview.on_navigate(fn (url string) {
							// 	exit(0)
							// })
						}
					),
					ui.button(
						text: 'Run javascript'
						on_click: fn (b &ui.Button) {
							// println("onclick javascript")
							// app.webview.exec("alert('Ran some javascript')")
						}
					),
				]
			),
		]
	)
	ui.run(window)
}

Outputs:

❯ v run test.v
test.v:11:6: warning: unused variable: `app`
    9 |
   10 | fn main() {
   11 |     mut app := &App{
      |         ~~~
   12 |         webview: voidptr(0)
   13 |     }
================== C compilation error (from tcc): ==============
cc: In file included from /usr/include/webkitgtk-4.0/webkit2/webkit2.h:38:
cc: /usr/include/webkitgtk-4.0/webkit/WebKitContextMenuItem.h:56: error: ',' expected (got "*")
...
cc: /usr/include/webkitgtk-4.0/webkit/WebKitContextMenuItem.h:56: error: ',' expected (got "*")
(note: the original output was 3 lines long; it was truncated to its first 2 lines + the last line)
=================================================================
(You can pass `-cg`, or `-show-c-output` as well, to print all the C error messages).
builder error:
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .

dy-tea avatar Nov 16 '25 00:11 dy-tea