ocamlbuild;建筑toplevel [英] ocamlbuild; building toplevel

查看:109
本文介绍了ocamlbuild;建筑toplevel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

成功使用子目录重新组织了我的ocamlbuild项目,并使用ocamlfind,我发现难以构建顶层。



我构建了一个 .mltop 文件所有包含的模块,并将包添加到 _tags ,但是构建不工作。它找不到使用其中一个模块编译的C函数。使用 -classic-display ,我可以看到该文件 libcs​​ide.a ,不包括在内,不是甚至编译了! c文件作为依赖关系添加到 myocamlbuild.ml 中,

  flag [link; ocaml; use_cutil](S [A-cclib; A-L。;]); 
dep [link; ocaml; use_cutil] [libcs​​ide.a];

_tags

 < utilities。*> :use_cutil 
< ** / *。top> :use_str,use_unix,use_cutil,use_curl,use_mysql

,最后在 libcs​​ide.clib

  cutil.o 

我在设置顶级构建时缺少一些东西,但是我找不到可靠的在线资源。

解决方案


  • 我假设cutil.ml描述了ocaml侧的libcs​​ide.a -

  • 使用当前插件cutil ocaml库不会链接libcs​​ide.a(

  • 这里有一个简单的(和工作的)方法来构建项目本地ocaml库C存根。在myocamlbuild.ml中:

      ocaml_liblinuxnet 
    let liblinuxnet_stubs =liblinuxnet_stubs。 ^!Options.ext_lib in
    flag [link; ocaml; use_linuxnet](S [A-cclib; A liblinuxnet_stubs;]);
    dep [link; ocaml; use_linuxnet] [liblinuxnet_stubs];

    在liblinuxnet_stubs.clib中:



    <$ p $请注意,C源代码被称为<$ c linuxnet_c.o


    $ c> linuxnet_c.c
    ,以便生成的目标文件不会覆盖从linuxnet.ml(或反之亦然)的文件。最后在_tags中:

      true:use_linuxnet 

    使用这个设置,它可以在toplevel(注意,没有必要把 Linuxnet 放入.mltop原因linuxnet.cma将被添加到链接 use_linuxnet 标志(使用 ocaml_lib 使用))



Having successfully reorganized my project for ocamlbuild with subdirectories and using ocamlfind, I've found it difficult to build the top-level.

I've constructed a .mltop file containing all the modules that would be included and added the packages to the _tags, but the build doesn't work. It cannot find the C functions that are compiled with one of the modules. With -classic-display on, I can see that file, libcside.a, not being included and isn't even being compiled at all! The c file is added as a dependency in myocamlbuild.ml by,

flag ["link"; "ocaml"; "use_cutil"] (S [A"-cclib"; A"-L."; ]);
dep  ["link"; "ocaml"; "use_cutil"] ["libcside.a"];

and in _tags,

<utilities.*> : use_cutil
<**/*.top> : use_str, use_unix, use_cutil, use_curl, use_mysql

and, finally, in libcside.clib,

cutil.o

I'm missing something in setting up the build for the top level, but I cannot find a reliable resource online. Thanks.

解决方案

  • I presume that cutil.ml describes ocaml side of libcside.a - correct?
  • Did you put Cutil in mltop?
  • With your current plugin cutil ocaml library will not link libcside.a in (dep only instructs ocamlbuild to build it, not link)
  • Here is a simple (and working) way to build project-local ocaml library with C stubs. In myocamlbuild.ml:

    ocaml_lib "linuxnet";
    let liblinuxnet_stubs = "liblinuxnet_stubs." ^ !Options.ext_lib in
    flag ["link"; "ocaml"; "use_linuxnet"] (S[A"-cclib"; A liblinuxnet_stubs;]);
    dep  ["link"; "ocaml"; "use_linuxnet"] [liblinuxnet_stubs];
    

    In liblinuxnet_stubs.clib:

    linuxnet_c.o
    

    Notice that the C source is called linuxnet_c.c so that the resulting object file doesn't override the one from linuxnet.ml (or vice versa). And finally in _tags:

    true: use_linuxnet
    

    With this setup it will be available in toplevel (note that there is no need to put Linuxnet into .mltop cause linuxnet.cma will be added to link by use_linuxnet flag (generated with ocaml_lib usage)).

这篇关于ocamlbuild;建筑toplevel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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