简体   繁体   中英

Ocaml Error : Unbound module when compiling

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM