1

我在标准 ML 中编译程序时遇到问题。

该程序运行良好,并且在我的本地机器上完美编译。但我希望能够静态编译它,以便在集群的其他地方执行它。

这是我用来编译程序的命令:

mton -verbose 3 -codegen native -output spartacus src/spartacus.mlb

这是文件src/spartacus.mlb

/usr/lib/mlton/sml/basis/basis.mlb
/usr/lib/mlton/sml/smlnj-lib/Util/smlnj-lib.mlb
/usr/lib/mlton/sml/mlyacc-lib/mlyacc-lib.mlb

util/listsort.sig.sml
util/listsort.sml

smlnj-lib/Binarymap.sml
smlnj-lib/Binaryset.sml

ds/dict.sig.sml
ds/binarydict.sml
ds/dynarraydict.sml

core/settings.sml

util/debug.sml
util/util.sml
util/exn.sig.sml
util/exn.sml
util/ref.sig.sml
util/ref.sml

ds/ubtree.sig.sml
ds/ubtree.sml
ds/bitmatrix.sig.sml
ds/bitmatrix.sml
ds/btprioq.sig.sml
ds/btprioq.sml

core/relationmgr.sig.sml
core/relationmgr.sml

preprocessing/parsetree.sml

core/term.sml

parsers/owlfs/owlfs.grm.sig
parsers/owlfs/owlfs.lex.sml
parsers/owlfs/owlfs.grm.sml
parsers/owlfs/owlfsparser.sml

parsers/lwb/lwb.grm.sig
parsers/lwb/lwb.lex.sml
parsers/lwb/lwb.grm.sml
parsers/lwb/lwbparser.sml

parsers/parser/grmspec.grm.sig
parsers/parser/lexspec.lex.sml
parsers/parser/grmspec.grm.sml
parsers/parser/parser.sml

parsers/ksatc/ksatc.grm.sig
parsers/ksatc/ksatc.lex.sml
parsers/ksatc/ksatc.grm.sml
parsers/ksatc/ksatcparser.sml

parsers/intohylo/intohylo.grm.sig
parsers/intohylo/intohylo.lex.sml
parsers/intohylo/intohylo.grm.sml
parsers/intohylo/intohyloparser.sml

parsers/alc/alc.grm.sig
parsers/alc/alc.lex.sml
parsers/alc/alc.grm.sml
parsers/alc/alcparser.sml

parsers/dimacs/dimacs.grm.sig
parsers/dimacs/dimacs.lex.sml
parsers/dimacs/dimacs.grm.sml
parsers/dimacs/dimacsparser.sml

parsers/dfg/dfg.grm.sig
parsers/dfg/dfg.lex.sml
parsers/dfg/dfg.grm.sml
parsers/dfg/dfgparser.sml

parsers/advtkb/tkbtree.sml
parsers/advtkb/advtkb.grm.sig
parsers/advtkb/advtkb.lex.sml
parsers/advtkb/advtkb.grm.sml
parsers/advtkb/advtkbparser.sml

parsers/tancs/tancs.grm.sig
parsers/tancs/tancs.lex.sml
parsers/tancs/tancs.grm.sml
parsers/tancs/tancsparser.sml

preprocessing/translator.sig.sml
preprocessing/translator.sml

util/dependency.sig.sml
util/dependency.sml

heuristics/penaltymap.sig.sml
heuristics/penaltymap.sml
heuristics/disjunctionpenalties.sig.sml
heuristics/disjunctionpenalties.sml

core/agenda.sig.sml
core/agenda.sml

ds/propstore.sig.sml
ds/propstore.sml
ds/termstore.sig.sml
ds/termstore.sml

opt/lazystore.sig.sml
opt/lazystore.sml
opt/lazyboxstore.sig.sml
opt/lazyboxstore.sml
opt/lazynomstore.sig.sml
opt/lazynomstore.sml

core/universalstore.sig.sml
core/universalstore.sml

core/existentialstore.sig.sml
core/existentialstore.sml

opt/cache.sig.sml
opt/treecache.sml
opt/mtrxcache.sml
opt/cache.sml

core/node.sig.sml
core/node.sml
core/nodestore.sig.sml
core/nodestore.sml

blocking/patternstore.sig.sml
blocking/listpatternstore.sml
blocking/treepatternstore.sml
blocking/mtrxpatternstore.sml
blocking/patternstore.sml
blocking/blockingmgr.sig.sml
blocking/blockingmgr.sml

core/branchingmgr.sig.sml
core/branchingmgr.sml
core/solver.sig.sml
core/solver.sml

output/helpmsg.sml
output/printsettings.sml
output/csvoutput.sml
output/modeloutput.sml
preprocessing/parser.sml
preprocessing/readargs.sml

core/main.sml

这是编译最后一部分的 StackTrace :

Compile and Assemble starting
        gcc -std=gnu99 -c -I/usr/lib/mlton/targets/self/include \
            -I/usr/lib/mlton/include -O1 -fno-common -fno-strict-aliasing \
            -fomit-frame-pointer -w -m64 -o /tmp/file97aS8t.o \
            /tmp/fileTVXUNZ.16.c
        gcc -c -m64 -o /tmp/fileEW5l8Q.o /tmp/filelhsimY.15.s
        gcc -c -m64 -o /tmp/filea6cMXC.o /tmp/fileGkFaoi.14.s
        gcc -c -m64 -o /tmp/filefyCq0e.o /tmp/fileXt7CAu.13.s
        gcc -c -m64 -o /tmp/file6aM9Ln.o /tmp/filemFDLpo.12.s
        gcc -c -m64 -o /tmp/file0xIwuN.o /tmp/fileRzsHqU.11.s
        gcc -c -m64 -o /tmp/file1sxl2Y.o /tmp/fileqwIZGn.10.s
        gcc -c -m64 -o /tmp/filetuKGWV.o /tmp/fileTg7gK0.9.s
        gcc -c -m64 -o /tmp/filebtu3gE.o /tmp/fileLAXFmK.8.s
        gcc -c -m64 -o /tmp/file0pRNH2.o /tmp/fileNOAFB8.7.s
        gcc -c -m64 -o /tmp/fileTxaQrb.o /tmp/fileWkQghY.6.s
        gcc -c -m64 -o /tmp/fileqh3aE2.o /tmp/filesqqcMD.5.s
        gcc -c -m64 -o /tmp/fileYYijnB.o /tmp/fileaRCFoK.4.s
        gcc -c -m64 -o /tmp/file7xPbic.o /tmp/fileXYwRmD.3.s
        gcc -c -m64 -o /tmp/fileVsXNP1.o /tmp/filefrBd1m.2.s
        gcc -c -m64 -o /tmp/fileykpidV.o /tmp/fileMIX5MM.1.s
        gcc -c -m64 -o /tmp/file4eH2rC.o /tmp/filegwauVv.0.s
     Compile and Assemble finished in 0.96 + 0.00 (0% GC)
     Link starting
        gcc -o spartacus /tmp/file97aS8t.o /tmp/fileEW5l8Q.o /tmp/filea6cMXC.o \
            /tmp/filefyCq0e.o /tmp/file6aM9Ln.o /tmp/file0xIwuN.o \
            /tmp/file1sxl2Y.o /tmp/filetuKGWV.o /tmp/filebtu3gE.o \
            /tmp/file0pRNH2.o /tmp/fileTxaQrb.o /tmp/fileqh3aE2.o \
            /tmp/fileYYijnB.o /tmp/file7xPbic.o /tmp/fileVsXNP1.o \
            /tmp/fileykpidV.o /tmp/file4eH2rC.o -L/usr/lib/mlton/targets/self \
            -lmlton -lgdtoa -lm -lgmp -m64 -Wl,-znoexecstack
     Link finished in 0.14 + 0.00 (0% GC)
  MLton finished in 46.39 + 7.31 (14% GC)

我检查了MLTon 文档,但没有看到任何与静态编译相关的信息:/

如果有人知道该怎么做,那将对我有很大帮助!提前致谢,

此致;


编辑

在集群上,当我尝试执行 ./spartacus

./spartacus: error while loading shared libraries: 
libgmp.so.10: cannot open shared object file: No such file or directory
4

1 回答 1

4

你需要编译使用-link-opt '-static'

mlton -verbose 3 \
      -codegen native \
      -link-opt '-static' \
      -output spartacus \
      src/spartacus.mlb
于 2015-11-25T14:31:28.557 回答