Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

bengimizrahi

macrumors newbie
Original poster
May 24, 2008
13
0
Istanbul
I got linkage error when I use a symbol in a static library.

Can anyone tell me how to do the following:

- foo.h:
Code:
int foo();

- foo.cpp:
Code:
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?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.