Re: Linking against a re-exported library
Re: Linking against a re-exported library
- Subject: Re: Linking against a re-exported library
- From: Ken Thomases <email@hidden>
- Date: Tue, 31 Dec 2013 03:30:38 -0600
On Dec 31, 2013, at 3:08 AM, Kyle Sluder wrote:
> The install name for libpq.5.6.dylib is actually "libpq.5.dylib", and it
> is configured to look for libssl and libcrypto in "@loader_path/../lib".
> Since I can't seem to change libpq's install name, […]
Why not?
> […] I'm copying all three
> dylibs to a "lib" subdirectory in the framework wrapper, and using a Run
> Script build phase to generate a wrapper PostgreSQL.dylib that
> re-exports the symbols from libpq:
>
> #--snip--
> EXECUTABLE_PATH="$TARGET_BUILD_DIR/$CONTENTS_FOLDER_PATH/$EXECUTABLE_NAME"
> ld -dylib -arch "$CURRENT_ARCH" -reexport_library
> "$TARGET_BUILD_DIR/$WRAPPER_NAME/lib/libpq.5.6.dylib" -o
> "$EXECUTABLE_PATH" -install_name "$LD_DYLIB_INSTALL_NAME"
> #--snip--
>
> This results in a framework with the following structure:
>
> PostgreSQL.framework/
> Versions/
> A/
> PostgreSQL
> lib/
> libpq.5.6.dylib
> libssl.1.0.0.dylib
> libcrypto.1.0.0.dylib
>
> Then, because libpq's install name was just plain "libpq.5.dylib" at the
> time my ld command created the wrapper dylib, my Run Script phase needs
> to patch up the wrapper dylib's load commands:
>
> #--snip--
> install_name_tool -change "libpq.5.dylib"
> "@rpath/$CONTENTS_FOLDER_PATH/lib/libpq.5.6.dylib" "$EXECUTABLE_PATH"
> #--snip--
Why are you using @rpath-based references here? What is supplying the run path list at load time? Wouldn't @loader_path-based references work, since the relative path between PostgreSQL and libpq.5.6.dylib is constant?
> otool shows the result:
>
> % otool -L PostgreSQL.framework/Versions/A/PostgreSQL
> PostgreSQL.framework/Versions/A/PostgreSQL:
> @rpath/PostgreSQL.framework/Versions/A/PostgreSQL (compatibility
> version 0.0.0, current version 0.0.0)
> @rpath/PostgreSQL.framework/Versions/A/Libraries/libpq.5.6.dylib
> (compatibility version 5.0.0, current version 5.6.0)
>
> That seems all well and good until my app's model library tries to link
> against this framework. Then ld complains:
>
> File not found:
> @rpath/PostgreSQL.framework/Versions/A/Libraries/libpq.5.6.dylib for
> architecture x86_64
Have you tried specifying an rpath for PostgreSQL? That is pass "-rpath @loader_path/../../.." to the earlier ld command for building PostgreSQL. Not sure if that will help, but it might.
Regards,
Ken
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden