-
Notifications
You must be signed in to change notification settings - Fork 5
Use Ocsfml
Type #use "topfind"
to active findlib feature. Then type #require "ocsfml.system"
, #require "ocsfml.window"
, #require "ocsfml.graphics"
,#require "ocsfml.audio"
,#require "ocsfml.network"
to load the corresponding files. You may then access the module you loaded.
The easiest method is to directly call ocamlfind
. For instance, if you want to produce a byte or native executable (called bar) from your file foo.ml (which use the modules graphics, window and system) you will type :
ocamlfind ocamlc -linkpkg -package 'ocsfml.graphics' foo.ml -o bar
ocamlfind ocamlopt -linkpkg -package 'ocsfml.graphics' foo.ml -o bar
Note that you only have to specify the package graphics : the module graphics depends on the modules window and system, ocamlfind automatically add the corresponding packages.
ocamlbuild is a tool which comes with ocaml (since ocaml 3.11) and ease the compilation process. To use Ocsfml with ocamlbuild and ocamlfind you can use the following command :
ocamlbuild -use-ocamlfind -package ocsfml.your-module your-file.byte
ocamlbuild -use-ocamlfind -package ocsfml.your-module your-file.native
Alternatively, you can use the _tags file, namely :
<your-file.{ml,byte,native}> : package ( ocsfml.your-module )
Then, when calling ocamlbuild just pass the -use-ocamlfind
argument.