【问题标题】:How to use -thread compiler flag with ocamlbuild?如何在 ocamlbuild 中使用 -thread 编译器标志?
【发布时间】:2013-05-14 21:03:39
【问题描述】:

我通过在_tags 中添加package(async_core) 来使用Jane Streetasync_core

当我使用ocamlbuild -use-ocamlfind -I src test/test_airport.native 时,它给了我以下错误:

camlfind ocamlopt -linkpkg -package async_core -package unix -package netclient -package mongo -package xml-light src/airport.cmx 测试/test_airport.cmx -o test/test_airport.native ocamlfind:错误 来自包 `threads':缺少 -thread 或 -vmthread 开关


我用谷歌搜索了一下,这是我得到的http://caml.inria.fr/pub/docs/manual-ocaml-4.00/manual039.html

上面写着:

使用系统线程的程序必须按如下方式链接:

    ocamlc -thread other options unix.cma threads.cma other files

所以我像这样更改了我的 ocamlbuild 命令:

ocamlbuild -use-ocamlfind -cflag -thread -I src test/test_airport.native

但错误仍然相同。没有-thread,ocamlbuild 生成的实际命令也保持不变。


我该如何处理?

【问题讨论】:

  • 谁这么讨厌我,以至于对我的每一个问题都投了反对票?

标签: ocaml ocamlbuild


【解决方案1】:

您想知道的是是否有一个 ocamlbuild 标记(~ 功能)可以将 -thread 参数添加到相关命令行,而不是使用 -cflag 以不令人满意的方式对其进行破解。正如in this blog post 解释的那样,您应该使用ocamlbuild 的-documentation 选项:

% ocamlbuild -documentation | grep thread
flag {. byte, link, ocaml, program, thread .} "threads.cma -thread"
flag {. link, native, ocaml, program, thread .} "threads.cmxa -thread"
flag {. doc, ocaml, thread .} "-I +threads"
flag {. compile, ocaml, thread .} "-thread"

所以答案是:将 -tag thread 添加到您的 ocamlbuild 调用中 行,或者只是thread_tags 的相关位置。

【讨论】:

  • 在极不可能的情况下,加什的答案不够清楚,这里是他们的一次谈话中使用的 _tags 文件 janestreet:bitbucket.org/yminsky/core-hello-world/src/…
  • 谢谢。我想我还没有理解 ocamlbuild 中的标签内容
  • @JacksonTale,换句话说,您必须在编译项目的目录中创建一个_tags 文件。 ocamlbuild 将在 _tags 文件中搜索标志,并使用您在 _tags 文件中指定的文件的相应标志调用必要的命令。
猜你喜欢
  • 2011-10-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-01-07
  • 2022-10-24
相关资源
最近更新 更多