How to add a static library into a iPhone project in XCode?

Discussion in 'iOS Programming' started by bengimizrahi, Nov 1, 2008.

  1. bengimizrahi
    Expand Collapse
    macrumors newbie


    May 24, 2008
    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?

Share This Page