cx_freeze linking to libraries in /opt/local rather than the ones it copied over

480 views Asked by At

I installed Python 3.4 and cx_freeze 4.3.4 on Macports and Mac OS 10.10, and built a frozen executable. However, a couple of linked libraries are pointing to their paths on my Macports installation in /opt/local.

From otool -L:

Load command 7
          cmd LC_LOAD_DYLINKER
      cmdsize 32
         name /usr/lib/dyld (offset 12)
Load command 8
     cmd LC_UUID
 cmdsize 24
    uuid 2CE48062-D852-3DD1-B4BD-F5A60227CD19
Load command 9
      cmd LC_VERSION_MIN_MACOSX
  cmdsize 16
  version 10.10
      sdk 10.10
Load command 10
      cmd LC_SOURCE_VERSION
  cmdsize 16
  version 0.0
Load command 11
       cmd LC_MAIN
   cmdsize 24
  entryoff 5424
 stacksize 0
Load command 12
          cmd LC_LOAD_DYLIB
      cmdsize 96
         name /opt/local/Library/Frameworks/Python.framework/Versions/3.4/Python (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 3.4.0
compatibility version 3.4.0
Load command 13
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /opt/local/lib/libintl.8.dylib (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 10.3.0
compatibility version 10.0.0

Both Python libintl.8.dylib, and libiconv.2.dylib were copied over alongside my frozen application, so loading them from /opt/local breaks portability on other systems.

dyld: Library not loaded:
/opt/local/Library/Frameworks/Python.framework/Versions/3.4/Python 

It looks like I'm not the only one who has experienced this problem.

Pyinstaller does not support python3 and py2app does not work for curses console applications, so I really need this to work.

1

There are 1 answers

2
peacer212 On

Check out https://github.com/auriamg/macdylibbundler, it is a great tool to gather dependencies of an executable on mac and to change the paths of dylibs via the install_name tool. Download it, compile it, and apply it to your executable via

dylibbundler -od -b -x ./pathto/executable -p @executable_path/relativepathtoyourexecutable/libs/

The readme on github also explains all parameters.