1

Sage 应该能够使用 Cython 创建编译代码。我从来没有让这个工作。问题似乎与我的 Sage 安装有关,因为在包含的示例上编译失败。我不相信我在安装过程中做了什么特别的事情,但显然我做错了。圣人教程

为了制作你自己的编译 Sage 代码,给文件一个 .spyx 扩展名(而不是 .sage)。如果您正在使用命令行界面,您可以像使用解释代码一样附加和加载编译代码(目前,笔记本界面不支持附加和加载 Cython 代码)。实际的编译是在“幕后”完成的,您无需做任何明确的事情。有关直接使用 GMP C 库的阶乘函数的编译实现示例,请参见 $SAGE_ROOT/examples/programming/sagex/factorial.spyx。要亲自尝试一下,cd 到 $SAGE_ROOT/examples/programming/sagex/,然后执行以下操作:

sage: load "factorial.spyx"

当我尝试时,我收到以下消息:

1-linux-32bit-ubuntu_10.04_lts-i686-Linux/devel/sage/sage/ext/-I/home/oliver/Desktop/sage-4.7.1-linux-32bit-ubuntu_10.04_lts-i686-Linux/devel /sage/ -I/home/oliver/Desktop/sage-4.7.1-linux-32bit-ubuntu_10.04_lts-i686-Linux/devel/sage/sage/gsl/ -I. -I/home/oliver/Desktop/sage-4.7.1-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/include/python2.6 -c _home_oliver_Desktop_sage_4_7_1_linux_32bit_ubuntu_10_04_lts_i686_Linux_examples_programming_sagex_factorial_spyx_0.c-2.6 build/ /_home_oliver_Desktop_sage_4_7_1_linux_32bit_ubuntu_10_04_lts_i686_Linux_examples_programming_sagex_factorial_spyx_0.o -w -O2 creating build/lib.linux-i686-2.6 gcc -pthread -shared build/temp.linux-i686-2.6/_home_oliver_Desktop_sage_4_7_1_linux_32bit_ubuntu_10_04_lts_i686_Linux_examples_programming_sagex_factorial_spyx_0.o -L/home/oliver/Desktop/sage-4.7.

/usr/bin/ld: 找不到 -lstdc++ collect2: ld 返回 1 退出状态错误:命令 'gcc' 失败,退出状态 1

有什么建议么?谢谢。

4

1 回答 1

2

根据 DSM 的评论,我重新安装了 g++-multilib,现在一切正常。

于 2012-03-02T21:48:22.293 回答