Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using "ocamlfind" to make the OCaml compiler and toplevel find (project specific) libraries

I'm trying to use ocamlfind with both the OCaml compiler and toplevel. From what I understood, I need to place the required libraries in the _tags file at the root of my project, so that the ocamlfind tool will take care of loading them - allowing me to open them in my modules like so :

open Sdl
open Sdlvideo
open Str

Currently, my _tags file looks like this :

<*>: pkg_sdl,pkg_str

I can apparently launch the ocamlfind command with the ocamlc or ocamlopt argument, provided I wan't to compile my project, but I did not see an option to launch the toplevel in the same manner. Is there any way to do this (something like "ocamlfind ocaml")?

I also don't know how to place my project specific modules in the _tags file : imagine I have a module name Land. I am currently using the #use "land.ml" directive to open the file and load the module, but it has been suggested that this is not good practice. What syntax should I use in _tags to specify it should be loaded by ocamlfind (considering land.ml is not in the ocamlfind search path) ?

Thank you, Charlie P.

Edit : According to the first answer of this post, the _tags file is not to be used with ocamlfind. The questions above still stand, there is just a new one to the list : what is the correct way to specify the libraries to ocamlfind ?

like image 606
CharlieP Avatar asked Dec 22 '22 06:12

CharlieP


1 Answers

try this:

$ cat >> .ocamlinit
#use "topfind";;
#require "sdl";;
#require "sdlvideo";;

open Sdl
open Sdlvideo;;
open Str;;

.ocamlinit is sourced from the current directory, falling back to /home/user/.ocamlinit. you can explicitly override it via ocaml -init <filename>

like image 67
Martin DeMello Avatar answered May 10 '23 21:05

Martin DeMello