【发布时间】:2014-11-25 20:21:44
【问题描述】:
我正在尝试在具有 OS 10.9 并运行 64 位 Python 的 64 位 Mac 上构建 cx_Freeze。 我正在运行的python 是Anaconda python distribution for mac(64 位)。我已经把它改成了默认的python。
进入cx_freeze源目录并运行python setup.py build时出现以下错误:
Creating build/lib.macosx-10.5-x86_64-2.7/cx_Freeze/bases
gcc -arch x86_64 build/temp.macosx-10.5-x86_64-2.7/source/bases/Console.o -L/Users/JJ/anaconda/lib -o build/lib.macosx-10.5-x86_64-2.7/cx_Freeze/bases/Console -s
ld: warning: option -s is obsolete and being ignored
Undefined symbols for architecture x86_64:
"_PyDict_New", referenced from:
_main in Console.o
"_PyDict_SetItemString", referenced from:
_main in Console.o
"_PyErr_Print", referenced from:
_main in Console.o
"_PyEval_EvalCode", referenced from:
_main in Console.o
"_PyEval_GetBuiltins", referenced from:
_main in Console.o
"_PyImport_ImportModule", referenced from:
_main in Console.o
"_PyObject_CallMethod", referenced from:
_main in Console.o
"_PyString_FromString", referenced from:
_main in Console.o
"_PySys_SetArgv", referenced from:
_main in Console.o
"_Py_FatalError", referenced from:
_main in Console.o
"_Py_Finalize", referenced from:
_main in Console.o
"_Py_FrozenFlag", referenced from:
_main in Console.o
"_Py_IgnoreEnvironmentFlag", referenced from:
_main in Console.o
"_Py_Initialize", referenced from:
_main in Console.o
"_Py_IsInitialized", referenced from:
_main in Console.o
"_Py_NoSiteFlag", referenced from:
_main in Console.o
"_Py_SetProgramName", referenced from:
_main in Console.o
"_Py_SetPythonHome", referenced from:
_main in Console.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'gcc' failed with exit status 1
这可能是什么问题?
【问题讨论】:
-
这还不足以继续下去。你是如何建造它的?输出的其余部分是什么(除其他外,它将向我们展示它在收到此错误时试图链接在一起的内容)?您使用的是 Apple 的 Python 还是第三方 Python(如果是后者,是哪一个,您是如何安装的)?
-
已用更多信息更新了问题。
-
所有这些缺失的函数都是标准 C API 的一部分。很明显,它正在尝试构建依赖于 libpython .dylib/.framework/.a 的东西(可能是一个可执行文件,没有用于构建库的标志,并且存在
_main),但没有链接到这样的库. (换句话说,在gcc命令行上应该有一个-lpython。)至于为什么会这样,我不知道。 -
其实,有一件事:你有什么版本的 Anaconda?它有多新?你有没有做任何事情来修改它的标准 distutils 配置?因为很难想象任何最近的 Mac 版 Python 发行版都会设置为明确指定
gcc。 -
Anaconda 完全是最新的。我已经安装了 XCode,它可能影响了 gcc。 gcc -v 给出:配置为:--prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM 5.1 版(clang -503.0.40)(基于 LLVM 3.4svn)目标:x86_64-apple-darwin13.1.0