Ocaml Error : Unbound module when compiling

3.4k views Asked by At

I'm learning Ocaml and currently I'm building a graphical interface for a game. I used Graphics and camlimages but now I would like to add some buttons. So I searched for Gtk2 and I'm having problems to compile now. This is a part of my code:

open Gamebase
open Game_imp
open Graphics
open Graphic_image 
open Images 
open Png 

let _ = GMain.init () 
 
let window = GWindow.window 
    ~title:"Simple lablgtk program"
    ~width:320 
    ~height:240 ()

I used

ocambuild -use-ocamlfind main.ml

before in order to compile combined with _tags file, but in order to include the gtk module, I tried

ocamlfind ocamlc -g -package lablgtk2 -linkpkg main.ml -o main

which seemed to work in a sample exemple, however when I combine it with my projet, I get "Error: Unbound module Gamebase". I tried

ocamlfind ocamlc -I +gamebase -g -package lablgtk2 -linkpkg main.ml -o main

but doesn't seem to work. Any hints and kind words are greatly appreciated.

1

There are 1 answers

6
Pierre G. On

Simply :

ocamlfind ocamlc -g -package lablgtk2 -linkpkg  gamebase.ml main.ml -o main

Just take care of the order with which you give the ml file : gamebase.ml must be given first, because main.ml has a dependency on it.