簡體   English   中英

如何為Mac 64位和Python 2.7.8 64位構建cx_freeze

[英]How to build cx_freeze for Mac 64 bit and Python 2.7.8 64 bit

我正在嘗試在OS 10.9和運行64位Python的64位Mac上構建cx_Freeze。 我正在運行的python是Mac (64位)的Anaconda python發行版 我已將其更改為默認的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

這里可能是什么問題?

其中的一條評論暗示了gcc命令應該在其中帶有標志“ -lpython”的事實。 這使我走上了正確的軌道。 在構建Console.o和ConsoleKeepPath.o時,可以通過添加標志“ -lpython2.7”來解決此問題。 我通過在下載的cx_Freeze-4.3.3目錄中的setup.py文件中添加以下行來實現此目的:

extensions[1].extra_link_args=['-lpython2.7']
extensions[2].extra_link_args=['-lpython2.7']

擴展名中包含3個元素,因此我使用extension [x] .name查找正確的元素。 完成此操作后,我能夠使用標准的python distutils進行構建和安裝。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM