[英]Why my ocaml program can't find module Clflags?
I am new to ocaml,I found this page: https://caml.inria.fr/pub/docs/manual-ocaml/libref/ 我是ocaml的新手,我找到了这个页面: https : //caml.inria.fr/pub/docs/manual-ocaml/libref/
is this page the ocaml standard lib? 这个页面是ocaml标准的lib吗?
when I write a program with one line: 当我用一行编写程序时:
open Marshal
ocamlc can build it ocamlc可以建立它
when I write 我写的时候
open Clflags
ocamlc give me error:Unbound module Cflags ocamlc给我错误:未绑定的模块Cflags
but Clflags and Marshal are both in the list of this page 但是Clflags和Marshal都在这个页面的列表中
when I try to install Clflags with opam,opam tell me can't find this package 当我尝试用opam安装Clflags时,opam告诉我找不到这个包
So how to use package Clflags? 那么如何使用包Clflags?
Thanks 谢谢
Cflags
is a module, that belongs to the compiler-libs
library, a library for compiler developers and those who are extending the compiler. Cflags
是一个模块,属于compiler-libs
库,是编译器开发人员和扩展编译器的库。 So most likely, you're looking into a wrong module. 所以很有可能,你正在寻找一个错误的模块。
To use it, you need to add the compiler-libs
folder to the search path and specify the library name that provides this module. 要使用它,您需要将compiler-libs
文件夹添加到搜索路径并指定提供此模块的库名称。 Some automation tools will do this for you, but on the low level (for native compilation) this will look like this (assuming that your code is in the test.ml
file): 一些自动化工具会为您执行此操作,但在较低级别(对于本机编译),这将看起来像这样(假设您的代码在test.ml
文件中):
ocamlopt -I +compiler-libs ocamlcommon.cmxa test.ml -o test
This is not the index of the standard library, but the index of all modules provided by the standard distribution, including the compiler's front-end modules, which Clflags
is a part of. 这不是标准库的索引,而是标准分发提供的所有模块的索引,包括编译器的前端模块, Clflags
是其中的一部分。
You can get the list of the standard library's modules here , and the "core", always opened module here . 你可以得到标准库的模块列表在这里 ,而“核心”,总是打开的模块在这里 。
Clflags
isn't really useful unless you are hacking the compiler itself, which isn't really the best task for a beginner. 除非你正在攻击编译器本身,否则Clflags
并不是真的有用,这对初学者来说并不是最好的任务。 You can find here in the documentation how to compile with it: 你可以找到这里的文件怎么用它来编译:
ocamlc other options -I +compiler-libs ocamlcommon.cma other files
But then again, you don't want to do it until you have a good grasp on OCaml and its compiler. 但话又说回来,在你很好地掌握OCaml及其编译器之前,你不想这样做。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.