Re: import static library
Re: import static library
- Subject: Re: import static library
- From: Nick Zitzmann <email@hidden>
- Date: Tue, 2 Dec 2008 21:29:11 -0700
On Dec 2, 2008, at 9:19 PM, BirdSong wrote:
Hi all,I have an external c++ static library and want to use it in
my cocoa project. I just drag the .a file into my project but seems
my code didn't find the methods in the library. I guess maybe I need
to set some link path or so, but I don't know how to set and which
parameter, does anyone have experience about it?suppose I have a
libTest.a static library and there is a method called int
showMeTheResult(). I want to use this method in my objective-c class
(which is part of my cocoa project), how to do it step by step?
You drag it into your project, however, there are two things you must
know about static libraries:
1. The linker normally only imports the symbols it thinks it needs.
Sometimes it gets it right, but often I've seen it get it wrong (and
more often than not, it gets it wrong when dealing with non-C
libraries). If it's not importing symbols for you, then you need to
add the -all_load linker flag to the other linker flags build setting.
2. If your static library has the same name as a dynamic library in
the libraries paths, then the linker will always link to the dynamic
library over the static one. There's no way to get it to change this
behavior. One workaround is to remove the static library from the link
build phase, and add an absolute path pointing to the static library
to the other linker flags build setting.
Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden