[英]ocamlbuild produces a blank archive file rather than an executable
Working on a Debian-based Linux distro (PopOS), I have a folder of files and a Makefile containing在基于 Debian 的 Linux 发行版(PopOS)上工作,我有一个文件文件夹和一个 Makefile 包含
MODULES=move score main draw setup
OBJECTS=$(MODULES:=.cmo)
TEST=test.byte
OCAMLBUILD=ocamlbuild -use-ocamlfind
MAIN=main.byte
# Recipes
default: build #first build (dependies) then run utop (command)
utop
build:
$(OCAMLBUILD) $(OBJECTS)
test:
$(OCAMLBUILD) -tag 'debug' $(TEST) && ./$(TEST)
play:
$(OCAMLBUILD) $(MAIN) && ./$(MAIN)
clean:
ocamlbuild -clean
When I call make build
it seems to work just fine, but the resulting .byte
files don't run.当我调用
make build
时,它似乎工作得很好,但是生成的.byte
文件没有运行。 In the terminal they show up in red, which indicates that the computer is understanding them to be archive files rather than executables.在终端中,它们以红色显示,这表明计算机将它们理解为存档文件而不是可执行文件。 When I try to run
./main.byte
it says the file cannot be found even though the file is listed in the directory.当我尝试运行
./main.byte
时,它说即使该文件已在目录中列出,也无法找到该文件。
Moreover, when I build this on a Mac it works just fine.此外,当我在 Mac 上构建它时,它工作得很好。 It builds the program and runs it correctly.
它构建程序并正确运行它。
Any thoughts about what this could be?关于这可能是什么的任何想法?
I'm not fully sure why this works on a Mac but not my Linux machine, but I did manage to play with this enough to get a solution.我不完全确定为什么这适用于 Mac 而不是我的 Linux 机器,但我确实设法使用它来获得解决方案。 If I change the Makefile to be
如果我将 Makefile 更改为
MODULES=move score main draw setup
OBJECTS=$(MODULES:=.cmo)
TEST=test.byte
OCAMLBUILD=ocamlbuild -use-ocamlfind
MAIN=main.byte
default: build
utop
build:
$(OCAMLBUILD) $(OBJECTS) $(MAIN)
test:
$(OCAMLBUILD) -tag 'debug' $(TEST) && ./$(TEST)
play:
$(OCAMLBUILD) $(MAIN) && ./$(MAIN)
clean:
ocamlbuild -clean
then the computer recognizes the executable.然后计算机识别可执行文件。
In your original Makefile, make build
does not run the command ocamlbuild $(MAIN)
which should create the bytecode executable.在您原来的 Makefile 中,
make build
不会运行应该创建字节码可执行文件的命令ocamlbuild $(MAIN)
。 You have to run make play
for the bytecode executable to be built.您必须运行
make play
才能构建字节码可执行文件。 In the modified Makefile, you included $(MAIN)
in the list of targets passed to ocamlbuild in your build
Makefile target, so now it is built by make build
.在修改后的 Makefile 中,您在
build
Makefile 目标中将$(MAIN)
包含在传递给 ocamlbuild 的目标列表中,因此现在它由make build
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.