2

I'm using the packages curl in order to make Http request (and the package str to use regex). I'm compiling the files in my project, no probleme and when I compile the file.byte with js_of_ocaml, I have these errors :

js_of_ocaml --disable genprim foo.byte

Missing primitives:
  helper_curl_easy_cleanup
  helper_curl_easy_duphandle
  helper_curl_easy_getinfo
  helper_curl_easy_init
  helper_curl_easy_perform
  helper_curl_easy_setopt
  helper_curl_global_init
  re_search_forward
  re_string_match

And when I included the generated js file, I have this error in the web console : Uncaught ReferenceError: helper_curl_global_init is not defined

I know that there is missing primitives and it's cause the error that I have but there is a solution to fix that ?

2 Answers 2

3

Some OCaml libraries use primitives written in plain C. For obvious reasons js_of_ocaml cannot link them to Javascript. In this case you need to implement them manually, which is mentioned in the manual.

Functions from Str module have equivalents in ECMAScript library, so probably you need to use them (if somebody didn't create helper module which has the same interface as Str and call Javascript functions under the hood)

Sign up to request clarification or add additional context in comments.

Comments

2

To do http requests in js_of_ocaml, you will need to use that module: http://ocsigen.org/js_of_ocaml/2.5/api/XmlHttpRequest

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.