mr_js
mr_js

Reputation: 1029

How to build cx_freeze for Mac 64 bit and Python 2.7.8 64 bit

I'm trying to build cx_Freeze on a 64-bit Mac with OS 10.9 and running 64 bit Python. The python I am running is the Anaconda python distribution for mac (64 bit). I have changed this to the default python.

The following error occurs when going into the cx_freeze source dir and running 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

What could be the issue here?

Upvotes: 1

Views: 1133

Answers (1)

mr_js
mr_js

Reputation: 1029

One of the comments alluded to the fact that the gcc command should have a flag '-lpython' in it. This put me on the right track. I was able to fix the problem by adding the flags '-lpython2.7' when the Console.o and ConsoleKeepPath.o were being built. I achieved this by adding the following lines to the setup.py file in the downloaded cx_Freeze-4.3.3 directory:

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

There are 3 elements in extension so I used extension[x].name to find the right ones. With this done, I was able to build and install using the standard python distutils.

Upvotes: 2

Related Questions