简体   繁体   English

Ocaml 错误:编译时未绑定模块

[英]Ocaml Error : Unbound module when compiling

I'm learning Ocaml and currently I'm building a graphical interface for a game.我正在学习 Ocaml,目前我正在为游戏构建图形界面。 I used Graphics and camlimages but now I would like to add some buttons.我使用了Graphicscamlimages ,但现在我想添加一些按钮。 So I searched for Gtk2 and I'm having problems to compile now.所以我搜索了 Gtk2,但现在编译时遇到了问题。 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之前为了编译结合_tags文件,但是为了包含 gtk 模块,我试过了

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" .这似乎在一个示例示例中有效,但是当我将它与我的项目结合使用时,我得到"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.只需注意您提供 ml 文件的顺序:必须首先提供gamebase.ml ,因为main.ml依赖于它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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