Re: C++ static library location and headers
Re: C++ static library location and headers
- Subject: Re: C++ static library location and headers
- From: Andreas Grosam <email@hidden>
- Date: Mon, 15 Apr 2013 20:00:19 +0200
On 15.04.2013, at 16:47, David Fitterman wrote:
> I have created a C++ static library. I can link to it in the project where it was created.
>
> I want to use the library in other projects. Where do I move the library and its headers so they can be linked by another project?
Usually, for a *static library project* you add a `Copy Files` Build Phase in order to copy the public headers. The Copy Files' `Destination` is set to "Products Directory" and the `Subpath` is set to include/${PRODUCT_NAME}
Xcode automatically inserts a header search path for the product linking against this static library, iff you have specified this dependency with the "Link Binary With Libraries" UI in the target build settings of the parent.
>
> The headers were marked as public when the library was created.
>
> Are the headers automatically associated with the library, or do they just need to reside in the same directory?
When the project is built, the binary of the static library and its headers (in a subfolder) simply reside in the Build Products Directory of the parent project.
>
> I have a feeling that I also need to set up some search rules to take care of this. If that is needed where are they set up: in Xcode or the user .login file?
You only need to add a search path (for binary and headers), if you like to put them elsewhere - that is in another folder than the default: include/${PRODUCT_NAME} for headers, and Products Directory for the binary.
You would specify this in the target build settings in "Header Search Paths" and "Library Search Paths" respectively.
I would recommend to use the default.
Note, you import/include the headers as follows:
#import <MyLibrary/header.h>
where "MyLibrary" shall equal ${PRODUCT_NAME}. If not, adjust the `Subpath` setting in the `Copy Files` build phase accordingly.
Andreas
>
>
> _______________________________________________
> 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
_______________________________________________
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