Thomas Vanhelden
Thomas Vanhelden

Reputation: 897

OCaml - Compiling multiple files into one executable

I've wrote a sudoku solver in OCaml and I want to create a single executable for it.

I've got 3 files: board.ml, solver.ml and main.ml

board.ml contains the type of the board, functions to read from files, check validity, ...

solver.ml contains the functions to solve a given sudoku. solver.ml uses functions from board.ml

main.ml is a program which uses functions from both board.ml and solver.ml to solve a sudoku provided by command line arguments.

I don't use .mli files because the signatures are defined in the .ml files like:

module Board :
    sig
        (* signature *)
    end
=
    struct
        (* implementations *)
    end

I've already been able to do this with all the code in board.ml like:

ocamlc board.mli board.ml main.ml -o sudoku_solver

The end result should be one executable called "sudoku_solver" so I can do:

./sudoku_solver "sudoku.txt"

Upvotes: 0

Views: 333

Answers (1)

ivg
ivg

Reputation: 35280

just use:

ocamlbuild main.native

and run it with

./main.native "sudoku.txt"

Upvotes: 2

Related Questions