16

I'm developing a C++ project by using Xcode 4.6.1 as IDE. Now, I'd like to add a static library mylib.a and the related header mylib.h.

I read about this solution, but it doesn't work (while clicking on Target Dependencies, the box is still remaining empty).

Is there a way to achieve this task?


UPDATE:

I created a group, then I added the file mylib.a on it. It seems to work fine, but at compile-time a warning as follows appears:

ld: warning: ignoring file /Users/vdenotaris/Desktop/Code/MyStaticLib/mylib.a, file was built for archive which is not the architecture being linked
(i386):/Users/vdenotaris/Desktop/Code/MyStaticLib/mylib.a
2

1 Answer 1

17

Target dependencies is used if your static library is created by another XCode project and you want to include this project, so that you can easily develop on both you library and the corresponding application.

If you want to include a foreign library you would select your target under TARGETS there you select the section Build Phases there you have the area Link Binary With Libraries into this area you would add your library either with drag & drop or with the + sign.

To add the include path you select your project under PROJECT there you select the area Build Settings there you have under Search Path the Points Header Search Paths this should include the path to the directory where the header is.

The difference between the settings in Project or Targets is that in Project it sets the default settings for all targets. In Targets you can change the settings per Target.

EDIT For the linking errors this two answers could be helpful:

Sign up to request clarification or add additional context in comments.

9 Comments

Thank you so much for the answer. I linked inside my project mylib.aand my lib.h; now, when I build, appears the following warning: ld: warning: ignoring file /Users/vdenotaris/Desktop/Code/MyStaticLib/mylib.a, file was built for archive which is not the architecture being linked (i386): /Users/vdenotaris/Desktop/Code/MyStaticLib/mylib.a. How can I resolve this error?
@vdenotaris are you developing an iOS app ?
No, I'm developing a C++ app for my Master's Thesis.
please show the Architectures, Valid Architectures and Supported Platforms for both you static library and application.
I suppose that the considered static library was built for x64, whereas my project is based on i386 arch.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.