On 9 Sep, 2007, at 14:38, Drew McCormack wrote:
> On 09/09/2007, at 11:11 AM, Ronald Oussoren wrote:
>> On 7 Sep, 2007, at 17:25, Drew McCormack wrote:
>>> I'm a PyObjC newbie, so please excuse me if this is a simple/dumb
>>> I want to build a PyObjC app that uses VTK. I have a Cocoa build
>>> of VTK. In the main function that starts the python interpreter, I
>>> added setenv calls for PYTHONPATH and DYLD_LIBRARY_PATH so that
>>> the VTK dylibs and shared object files would be found. When I run
>>> the app from Xcode, I get an exception because it can't find a
>>> dyld: Library not loaded: libvtkCommon.5.0.dylib
>>> Referenced from: /Users/cormack/Develop/Build/Debug/
>>> Reason: image not found
>>> I figured maybe I had to link the VTK dylib into the main
>>> executable, so I added them to the project, but I still get errors
>>> related to missing dylibs, even though the dylibs are in the
>>> DYLD_LIBRARY_PATH set with setenv.
>>> Can anyone advise me how to correctly add dylibs from an external
>>> module to a PyObjC app?
>> Setting DYLD_LIBRARY_PATH mostly likely means that somethings wrong
>> with your environment or installation of VTK (or even VTK in
>> general). Settings DYDL_LIBRARY_PATH should never be necessary on
>> OSX and can cause vague problems all by itself.
> Is that because the executable path is stored in the dylibs?
Yes. IIRC setting DYLD_LIBRARY_PATH fully or partially disables two-
level namespaces as well
> So how should I go about 'importing' VTK into the pyobjc project?
> Should I add the VTK dylibs to the pyobjc Xcode project so that they
> get linked to the app executable? What about the VTK .so files? (I
> guess they are disguised dylibs) Should I link those into the Xcode
> executable too?
You could manually patch the main python file that py2app generates to
do the same environment settings that you do on the command-line.
The best long-term solution is to ensure that VTK can be imported
without settings DYLD_LIBRARY_PATH, that way py2app can automaticly
pick up libraries and rewrite their loading paths.