5
votes

I tried two commands to load Str Module in OCaml top level. The first command gives me the error "Cannot find file Str.cmo". I then tried to use the file i was using in top level with the second command. With that command i got "Reference to undefined global Str".

#load "Str.cmo";;

#use "my_file.ml";;

What do i need to do to successfully load Str module in OCaml top level.

2

2 Answers

10
votes
# #use "topfind";;
# #require "str";;
9
votes

Modules are "archives", so they are .cma files, not .cmo:

# #load "str.cma";;
# Str.regexp;;
- : string -> Str.regexp = <fun>