v icon indicating copy to clipboard operation
v copied to clipboard

Error when compiling the ui counter example to javascript

Open symil opened this issue 4 years ago • 9 comments
trafficstars

I just installed v and ran the counter example of the ui library. It works when I run it with v run counter.v, but fails when I try to compile it to Javascript with v -o counter.js counter.v with the error:

/home/ytawo/prog/v/vlib/strings/builder.v:10:12: error: cannot register struct `strings.Builder`, another type with this name exists

(it also gives me a ton of warnings)

Output of v doctor:

OS: linux, Ubuntu 18.04.5 LTS
Processor: 6 cpus, 64bit, little endian, Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz
CC version: cc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0

getwd: /home/ytawo/prog/prototype
vmodules: /home/ytawo/.vmodules
vroot: /home/ytawo/prog/v
vexe: /home/ytawo/prog/v/v
vexe mtime: 2021-01-06 07:48:05
is vroot writable: true
is vmodules writable: true
V full version: V 0.2.1 42e60b8

Git version: git version 2.17.1
Git vroot status: 0.2-318-g42e60b8e
.git/config present: true
thirdparty/tcc status: thirdparty-linux-amd64 7543de81

symil avatar Jan 06 '21 08:01 symil

Big parts of vlib and V UI are not yet ready for the JS backend

serkonda7 avatar Jan 07 '21 10:01 serkonda7

@playXE

danieldaeschle avatar Jul 22 '21 06:07 danieldaeschle

This one for sure will not be able to fix in close future. C FFI is required to run gg module which requires us to use node-ffi module or extend NodeJS with pre-compiled dynamic library.

playXE avatar Jul 28 '21 07:07 playXE

the goal is to make gg work inside the browser by rendering to a canvas.

spaceface777 avatar Jul 28 '21 09:07 spaceface777

@spaceface777 running gg in browser should be easier but we still need to run it on the Node backend too.

playXE avatar Jul 28 '21 10:07 playXE

@spaceface777 running gg in browser should be easier but we still need to run it on the Node backend too.

Curious why you would want to run gg on the Node backend? It makes sense for sake of consistency, but if you want a backend/desktop application why not just compile to an executable and call it done? Why does Node matter especially since Node doesn't actually have any built in functionality for graphics? You're essentially compiling to js so js (Node) can call C instead of just compiling directly to C. I'm guessing there is a valid reason you'd want to do this but I have no idea what it is, aside from consistency in the JS backend's functionality across Node and the browser

phillvancejr avatar Apr 26 '22 15:04 phillvancejr

The CI runs tests on the js backend using node, so it needs to work with node for that reason.

Personally, I'd rather see node go the way of the dodo, but it's not my call.

JalonSolov avatar Apr 26 '22 15:04 JalonSolov

Hi @symil, that example doesn't exists anymore, can you send a code to try to replicate?

esquerbatua avatar Sep 26 '24 23:09 esquerbatua

Hello, unfortunately it's been years and I don't have the code on my machine anymore 🙁

symil avatar Sep 27 '24 08:09 symil