Skip to content

when building js_of_ocaml program: "while linking cmo, the external function [...] is not available" #4027

@TyOverby

Description

@TyOverby

Expected Behavior

(executable
 (name foo)
 (modes js)
 (libraries bonsai.web core_kernel)
 (js_of_ocaml (flags --no-sourcemap) (javascript_files example.js))
 (preprocess (pps ppx_jane js_of_ocaml-ppx)))

In this executable, which is for , I link "example.js" which defines some external functions. In the ocaml code, I use

external my_extern_fun: (float Js.js_array Js.t -> float) -> unit = "my_extern_fun"

I expect this program to build.

Actual Behavior

The build fails with the following

$ dune build @default
File "_none_", line 1: 
Error: Error while linking ui/.pixelmapper.eobjs/byte/dune__exe__Pixelmapper.cmo:
       The external function `my_extern_fun' is not available

If I ask for just the .bc.js file, there is no error

$ dune build ui/pixel_mapper.bc.js
Done: 0/0 (jobs: 0)

and the file is built correctly.

The fact that @default is doing something extra that fails is quite confusing.

Specifications

  • Version of dune (output of dune --version): 2.7.1
  • Version of ocaml (output of ocamlc --version): 4.10.1

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions