如何使用scheme2c编译文件

发布于 2025-02-07 12:18:10 字数 3855 浏览 2 评论 0原文

我正在尝试使用 scheme2c (dec scheme-> c compiler)来编译计划程序。这是程序hello.sc

(module hello (main run-main))

(define (run-main)
  (display "Hello!")
  (newline))

我尝试使用scc hello.sh.sc来编译程序,但是这些链接器错误消息失败了:

hello.sc:
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scinit.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(apply.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(callcc.o): relocation R_X86_64_32S against symbol `sc_display' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(cio.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(heap.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(objects.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scdebug.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(sceval.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scexpand.o): relocation R_X86_64_32S against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scexpnd1.o): relocation R_X86_64_32S against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scexpnd2.o): relocation R_X86_64_32S against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(screp.o): relocation R_X86_64_32S against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scrt1.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scrt2.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scrt3.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scrt4.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scrt5.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scrt6.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scrt7.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scqquote.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
collect2: error: ld returned 1 exit status

我如何编译方案使用SCC的程序?

(ubuntu 20.04.4 lts上的spone2c版本2012.10.14)

I am trying to compile a Scheme program using scheme2c (the DEC Scheme->C Compiler). This is the program hello.sc:

(module hello (main run-main))

(define (run-main)
  (display "Hello!")
  (newline))

I tried to compile the program using scc hello.sc, but the compilation fails with these linker error messages:

hello.sc:
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scinit.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(apply.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(callcc.o): relocation R_X86_64_32S against symbol `sc_display' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(cio.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(heap.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(objects.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scdebug.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(sceval.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scexpand.o): relocation R_X86_64_32S against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scexpnd1.o): relocation R_X86_64_32S against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scexpnd2.o): relocation R_X86_64_32S against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(screp.o): relocation R_X86_64_32S against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scrt1.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scrt2.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scrt3.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scrt4.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scrt5.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scrt6.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scrt7.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scqquote.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
collect2: error: ld returned 1 exit status

How do I compile a Scheme program using scc?

(scheme2c version 2012.10.14 on Ubuntu 20.04.4 LTS)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灵芸 2025-02-14 12:18:10

默认情况下,在Ubuntu的GCC中启用了PIE(Ubuntu使用-Enable-Default-Pie选项编译GCC)。

可以通过使用GCC的-no-pie选项来解决该问题:

$ scc -cc 'gcc -no-pie' hello.sc
hello.sc:
$ ./a.out
Hello!

PIE is enabled by default in Ubuntu's GCC (Ubuntu compiles GCC using the --enable-default-pie option).

The problem can be solved by using GCC's -no-pie option:

$ scc -cc 'gcc -no-pie' hello.sc
hello.sc:
$ ./a.out
Hello!
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文