View Full Version : How to add a static library into a iPhone project in XCode?

Nov 1, 2008, 01:31 PM
I got linkage error when I use a symbol in a static library.

Can anyone tell me how to do the following:

- foo.h:
int foo();

- foo.cpp:
int foo() {
return 1;

- produce libfoo.a from foo.cpp

and then:

- Create an empty iPhone project in XCode
- add the directory of foo.h to the 'Header Search Paths'
- add the directory of libfoo.a to the 'Library Search Paths'
- add the library to the project (-lfoo)
- include foo.h in main.m
- call foo() in main.m

I get 'undefined symbol _foo'.

Did anyone achieved this?