why does `make` using _CoqProject in coqide differ from `coqc` on the commandline?

喜你入骨 提交于 2021-02-09 11:12:21

问题


I have two short files: cc_test is given by Lemma cc: 4 = 4. Proof. auto. Qed. and libtest is given by Require Import cc_test. Check cc.

When I execute coqc -R . ClosureLib -top ClosureLib cc_test in directory "/home/barry/svn/Coq/Closure_Calculus" and coqc -R "/home/barry/svn/Coq/Closure_Calculus" ClosureLib libtest in its directory, I get the expected output cc: 4 = 4

However, when the arguments to coqc above (from -R to the end) are placed in _CoqProject files, and I call Make makefile and then Make from the coqide menu, cc_test is okay but libtest yields output File "./libtest.v", line 1, characters 15-22: Error: Unable to locate library cc_test.

How should I modify the project files to make this work?

Comment: the coq reference manual (Chapter 15) does not mention any differences between these approaches. Also, the argument "-top ClosureLib" seems to be necessary in the commandline approach, but does not appear to matter using make as, in other experiments, I frequently get error messages saying that it found Top.foo but not ClosureLib.foo.


回答1:


First, I do not think -top ClosureLib is useful here. The documentation describes -top as

Not valid for coqc as the toplevel module name is inferred from the name of the output file

As for your main question, I must admit my solution is to install the dependencies using

coq_makefile -f _CoqProject -o Makefile
make
make install

make install puts the libraries in user-contrib, a place where they will be loaded automatically. You can then use Require directly.

EDIT:

Thanks to @Zimm48, I understood how to use $COQPATH to accomplish the same task without having to install the dependencies first. But the name of the folder will be used as the logical prefix, so you must use the same identifier in the -R or -Q argument and for the name of the directory.

I would suggest to use the following architecture:

  • in directory /home/barry/svn/Coq/ClosureLib (note that I renamed the directory, so that its name is identical to the identifier passed to -R), _CoqProject contains

    -R . ClosureLib
    cc_test.v
    

    You compile cc_test.v as follows:

    coq_makefile -f _CoqProject -o Makefile
    make
    
  • in the directory containing libtest.v, _CoqProject contains

    -R . MyLib
    libtest.v
    

    You can compile libtest.v as follows:

    coq_makefile -f _CoqProject -o Makefile
    COQPATH=/home/barry/svn/Coq make
    


来源:https://stackoverflow.com/questions/47087271/why-does-make-using-coqproject-in-coqide-differ-from-coqc-on-the-commandlin

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!