Reputation: 2927
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 ?
Upvotes: 2
Views: 429
Reputation: 1489
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
Upvotes: 2
Reputation: 2839
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)
Upvotes: 3