【发布时间】:2012-02-23 21:05:41
【问题描述】:
Sage 应该能够使用 Cython 创建编译代码。我从来没有让这个工作。问题似乎与我的 Sage 安装有关,因为在包含的示例上编译失败。我不相信我在安装过程中做了什么特别的事情,但显然我出了点问题。 Sage tutorial 说
为了制作您自己的编译 Sage 代码,请给文件一个 .spyx 扩展名(而不是 .sage)。如果您正在使用命令行界面,您可以像使用解释代码一样附加和加载编译代码(目前,笔记本界面不支持附加和加载 Cython 代码)。实际的编译是在“幕后”完成的,您无需做任何明确的事情。有关直接使用 GMP C 库的阶乘函数的编译实现示例,请参见 $SAGE_ROOT/examples/programming/sagex/factorial.spyx。要亲自尝试,请 cd 到 $SAGE_ROOT/examples/programming/sagex/,然后执行以下操作:
sage: load "factorial.spyx"
当我尝试时,我收到以下消息:
正在编译 ./factorial.spyx... 编译 cython 文件时出错: 编译 ./factorial.spyx 时出错: 运行构建 运行 build_ext 构建“_home_oliver_Desktop_sage_4_7_1_linux_32bit_ubuntu_10_04_lts_i686_Linux_examples_programming_sagex_factorial_spyx_0”扩展 创建构建 创建 build/temp.linux-i686-2.6 gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I/home/oliver/Desktop/sage-4.7.1-linux-32bit-ubuntu_10.04_lts-i686- Linux/local/include/csage/ -I/home/oliver/Desktop/sage-4.7.1-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/include/ -I/home/oliver/Desktop/sage- 4.7.1-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/include/python2.6/-I/home/oliver/Desktop/sage-4.7.1-linux-32bit-ubuntu_10.04_lts-i686-Linux /local/lib/python2.6/site-packages/numpy/core/include -I/home/oliver/Desktop/sage-4.7.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 创建 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.1-linux-32bit-ubuntu_10.04/libs/i686-Linux -L/home/wstein/build/sage-4.7.1/local/lib -lmpfr -lgmp -lgmpxx -lstdc++ -lpari -lm -lcurvesntl -lg0nntl -ljcntl -lrankntl -lgsl -lgslcblas -latlas -lntl -lcsage -lpython2 .6 -o build/lib.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.so -L/home/oliver/Desktop/sage-4.7.1-linux-32bit-ubuntu_10.04_lts-i6 p>
/usr/bin/ld: 找不到 -lstdc++ collect2: ld 返回 1 退出状态 错误:命令“gcc”失败,退出状态为 1
有什么建议吗?谢谢。
【问题讨论】:
-
(1) 你能正常编译调用-lstdc++的c++代码吗? (2) /home/wstein/ 不应该在路径上,但我通常使用进行一些重新指向的源构建。
-
谢谢。这正是我需要听到的。我重新安装了 g++-multilib,现在它工作正常了。
-
很高兴听到这个消息。两个注意事项:首先,您可以写下您的评论作为答案并接受它。其次,您通常可以在 ask.sagemath.org 上获得更具体的 Sage 帮助,那里有相当多的开发人员在此闲逛。