|
From: David F. <dav...@in...> - 2015-03-31 18:34:46
|
Quoting Carlos Liam (2015-03-31 18:51:20)
>
> > On Mar 31, 2015, at 12:46 PM, David Froger <dav...@in...> wrote:
> >
> >> g++ -L/Users/aarzee/Documents/steamworks-sdk/redistributable_bin/osx32 -shared -o -libpysteam_api.dylib -lsteam_api -lpython steamworks_wrap.o
> >
> > There is a typo:
> > g++ -L/Users/aarzee/Documents/steamworks-sdk/redistributable_bin/osx32 -shared -o libpysteam_api.dylib -lsteam_api -lpython steamworks_wrap.o
>
> Thank you, this worked. I'm currently using this command:
>
> g++ -shared -L/Users/aarzee/Documents/steamworks-sdk/redistributable_bin/osx32 -lsteam_api -lpython steamworks_wrap.o -o _steamworks.so
>
> However, when I tried to import the wrapper in the Python shell, I got this error:
>
> Python 2.7.6 (default, Sep 9 2014, 15:04:36)
> [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import steamworks
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "steamworks.py", line 28, in <module>
> _steamworks = swig_import_helper()
> File "steamworks.py", line 24, in swig_import_helper
> _mod = imp.load_module('_steamworks', fp, pathname, description)
> ImportError: dlopen(./_steamworks.so, 2): Library not loaded: @loader_path/libsteam_api.dylib
> Referenced from: /Users/aarzee/Documents/airship-py/_steamworks.so
> Reason: image not found
>
> This was fixed by copying libsteam_api.dylib to the folder I was working in, but I'm wondering how I can get the wrapper to find the .dylib by itself (if given a path).
libsteam_api.dylib is a dependant library of _steamworks.so .
When loaded, _steamworks.so will in turn loads libsteam_api.dylib.
If you issue the command:
otool -D /path/to/libsteam_api.dylib
you should see that libsteam_api.dylib install_name is:
@loader_path/libsteam_api.dylib
so when creating _steamworks.so, this path is stored in _steamworks.so .
You can see it with:
otool -L _steamworks.so
When loaded, _steamworks.so searches libsteam_api.dylib in path
@loader_path/libsteam_api.dylib, where @loader_path is the directory
containing _steamworks.so.
So, if you make a proper installation of both libsteam_api.dylib and _steamworks.so,
they will be in the same directory, and it will works.
You can set environment variable DYLD_LIBRARY_PATH to the directory containing
libsteam_api.dylib
Or in _steamworks.so, you can change the install_name of the dependent library libsteam_api.dylib
with:
install_name_tool -change @loader_path/libsteam_api.dylib /absolute/path/to/libsteam_api.dylib _steamworks.so
Or you can change the install_name in libsteam_api.dylib (and the re-create _steamworks.so to
take into account the modification):
install_name_tool -id /absolute/path/to/libsteam_api.dylib libsteam_api.dylib
My memo about that:
https://github.com/conda/conda-build/issues/279#issuecomment-67241554
|