如何在ocamlbuild中使用-thread编译器标志? [英] How to use -thread compiler flag with ocamlbuild?

查看:95
本文介绍了如何在ocamlbuild中使用-thread编译器标志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using Jane Street's async_core by adding package(async_core) in _tags.

当我使用ocamlbuild -use-ocamlfind -I src test/test_airport.native时,会出现以下错误:

When I use ocamlbuild -use-ocamlfind -I src test/test_airport.native, it gives me the following error:

camlfind ocamlopt -linkpkg -package async_core -package unix -package netclient -package mongo -package xml-light src/airport.cmx test/test_airport.cmx -o test/test_airport.native ocamlfind:错误 来自线程"包的消息:缺少-thread或-vmthread开关

camlfind ocamlopt -linkpkg -package async_core -package unix -package netclient -package mongo -package xml-light src/airport.cmx test/test_airport.cmx -o test/test_airport.native ocamlfind: Error from package `threads': Missing -thread or -vmthread switch


我用Google搜索了,这就是我 http://caml.inria所得到的. fr/pub/docs/manual-ocaml-4.00/manual039.html

它说:

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

Programs that use system threads must be linked as follows:

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

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

So I changed my ocamlbuild command like this:

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

但是错误仍然相同.不用-thread,ocamlbuild生成的实际命令也将保持不变.

But the error remains the same. also the actual command that ocamlbuild generated remains the same without -thread.

我该如何处理?

推荐答案

您想知道的是是否存在ocamlbuild标记(〜功能),将-thread参数添加到相关的命令行中,而不是进行黑客攻击-cflag以不令人满意的方式显示它.如此博客文章中所述,您应该使用ocamlbuild的-documentation选项:

What you want to know is whether there is an ocamlbuild tag (~ feature) to add the -thread argument to the relevant command-lines, instead of hacking it with -cflag in unsatisfying ways. As explained in this blog post, you should use the -documentation option of ocamlbuild:

% 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"

所以答案是:在您的ocamlbuild调用中添加-tag thread 行,或者只是在_tags中相关位置的thread.

So the answer is: add -tag thread to your ocamlbuild invocation line, or just thread in the relevant place in _tags.

这篇关于如何在ocamlbuild中使用-thread编译器标志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆