本文介绍了ocamlopt链接错误代码2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行了命令opam install ocamlbuild,看来我在ocamlopt上遇到了某种问题

I ran the command opam install ocamlbuild and it seems that I have some kind of problem with ocamlopt

这是opam告诉我的:(我猜它只是不喜欢我的4.04版本)

Here is what opam is telling me : (I'm guessing it just doesn't like my 4.04 version)

### stdout ###
# [...]
# mkdir -p tmp
# ocamlopt.opt -pack src/const.cmx src/loc.cmx src/discard_printf.cmx src/signatures.cmi src/my_std.cmx src/my_unix.cmx src/tags.cmx src/display.cmx src/log.cmx src/shell.cmx src/bool.cmx src/glob_ast.cmx src/glob_lexer.cmx src/glob.cmx src/lexers.cmx src/param_tags.cmx src/command.cmx src/ocamlbuild_config.cmx src/ocamlbuild_where.cmx src/slurp.cmx src/options.cmx src/pathname.cmx src/configuration.cmx src/flags.cmx src/hygiene.cmx src/digest_cache.cmx src/resource.cmx src/rule.cmx src/solver.cmx src/report.cmx src/tools.cmx src/fda.cmx src/findlib.cmx src/ocaml_arch.cmx src/ocaml_utils.cmx src/ocaml_dependencies.cmx src/ocaml_compiler.cmx src/ocaml_tools.cmx src/ocaml_specific.cmx src/exit_codes.cmx src/plugin.cmx src/hooks.cmx src/main.cmx -o tmp/ocamlbuild_pack.cmx
# mv tmp/ocamlbuild_pack.cmx src/ocamlbuild_pack.cmx
# mv tmp/ocamlbuild_pack.o src/ocamlbuild_pack.o
# ocamlopt.opt -for-pack Ocamlbuild_pack -w L -w R -w Z -I src -I +unix -safe-string -bin-annot -c src/ocamlbuild_plugin.ml
# ocamlopt.opt -for-pack Ocamlbuild_pack -w L -w R -w Z -I src -I +unix -safe-string -bin-annot -c src/ocamlbuild_executor.ml
# ocamlopt.opt -for-pack Ocamlbuild_pack -w L -w R -w Z -I src -I +unix -safe-string -bin-annot -c src/ocamlbuild_unix_plugin.ml
# ocamlopt.opt -for-pack Ocamlbuild_pack -w L -w R -w Z -I src -I +unix -safe-string -bin-annot -c src/ocamlbuild.ml
# ocamlopt.opt -I +unix -I src -o ocamlbuild.native unix.cmxa src/ocamlbuild_pack.cmx src/ocamlbuild_plugin.cmx src/ocamlbuild_executor.cmx src/ocamlbuild_unix_plugin.cmx src/ocamlbuild.cmx
# Makefile:131: recipe for target 'ocamlbuild.native' failed
### stderr ###
# [...]
# /usr/bin/ld: /home/oleg/.opam/4.04.0/lib/ocaml/libasmrun.a(finalise.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
# /usr/bin/ld: /home/oleg/.opam/4.04.0/lib/ocaml/libasmrun.a(custom.o): relocation R_X86_64_32 against symbol `caml_custom_table' can not be used when making a shared object; recompile with -fPIC
# /usr/bin/ld: /home/oleg/.opam/4.04.0/lib/ocaml/libasmrun.a(unix.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
# /usr/bin/ld: /home/oleg/.opam/4.04.0/lib/ocaml/libasmrun.a(backtrace.o): relocation R_X86_64_32 against symbol `caml_backtrace_last_exn' can not be used when making a shared object; recompile with -fPIC
# /usr/bin/ld: /home/oleg/.opam/4.04.0/lib/ocaml/libasmrun.a(startup.o): relocation R_X86_64_32S against symbol `caml_data_segments' can not be used when making a shared object; recompile with -fPIC
# /usr/bin/ld: final link failed: Nonrepresentable section on output
# collect2: error: ld returned 1 exit status
# File "caml_startup", line 1:
# Error: Error during linking
# make: *** [ocamlbuild.native] Error 2

谢谢.

推荐答案

从输出来看,您可以尝试重新安装当前为4.04.0的当前开关.

You could try reinstalling the current switch, which looks to be 4.04.0, judging from the output.

运行opam switch reinstall 4.04.0应该重新编译ocamlopt.opt二进制文件.

Running opam switch reinstall 4.04.0 should recompile the ocamlopt.opt binary.

这篇关于ocamlopt链接错误代码2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 17:46