I see you're already using -dylib_install_name to set the install name, which is fine, except that you need to specify the absolute path, not just the filename. The attached patch resolves this part of the issue, and using -dynamiclib instead of -shared. The library name problem remains.