dbuenzli / vg

Declarative 2D vector graphics for OCaml
http://erratique.ch/software/vg
ISC License
88 stars 12 forks source link

No implementations provided for Vgr_svg. #28

Closed davesnx closed 3 years ago

davesnx commented 3 years ago

Hi @dbuenzli

First of all, thanks for this library and its documentation. It's truly high class. I'm working with the basics examples where there's a grey square and as a target, I want to use svg. I have the following code unable to compile due an error:

open Gg
open Vg

let square i =
  let size = Size2.v 30. 30. in
  let view = Box2.unit in
  let buffer = Buffer.create 2048 in
  try
    let target = Vgr_svg.target ~xml_decl:true () in
    let renderer = Vgr.create target (`Buffer buffer) in
    ignore (Vgr.render renderer (`Image (size, view, i)));
    ignore (Vgr.render renderer `End);
    buffer
  with | (Sys_error e) -> (prerr_endline e; buffer)

let gray = I.const (Color.gray 0.5)

let render (_data : Image.t) =
  (Lwt.return ((square gray) |> Buffer.contents) : string Lwt.t)
File "_none_", line 1:
Error: No implementations provided for the following modules:
         Vgr_svg referenced from source/app/app.cmxa(App__Svg)

I'm not sure what's the issue here, since it fails at compiling but my lsp works fine with Vg.Vgr_svg.

davesnx commented 3 years ago

My bad. I found out that there's a note on how to compile it...

My dune file had:

(library
 (name app)
 (libraries vg)

It missed the vg.svg