1

I have a static Library X which is in C. I have another static library Y which is in objective C and its .mm files refer to function of Library X. Now in a single view application I have used Library Y. But during Compilation its giving an error saying

Undefined symbols for architecture i386:
  "encode()", referenced from:
      _playMediaInternal in libXMedia.a(XMediaInternal.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The above encode function is present in library X which is being used by Library Y and this is used by Single view application. Any suggestions ? I have seen other queries along the same line but had no luck with those. Another thread link

From the Apple developer site i have been trying to use static libraries link.

I have connected my phone to the Laptoop and have started compiling against it. its still giving me error. now i feel it has something to do with linking itself rather than architecture

Community
  • 1
  • 1
Titus
  • 187
  • 2
  • 15

2 Answers2

5

I have got the Answer from the stackoverflow link The Answer

I am pasting the exact thing. For me the issue was with the header which was having C Based function call

If you are using c function in c++ file. you should use extern "c"{}. In .h file

#ifdef __cplusplus
extern "C" {
#endif

swrve_currency_given(parameter1, parameter2, parameter3);// a c function


#ifdef __cplusplus
}
#endif  

extern "C" is meant to be recognized by a C++ compiler and to notify the compiler that the noted function is (or to be) compiled in C style.

If you're linking to a library that was compiled as C code. use

extern "C" {
  #include "c_only_header.h"
}

Take a look at When to use extern "C" in C++?

Community
  • 1
  • 1
Titus
  • 187
  • 2
  • 15
0

Your library compiled for ARM architecture, and you try run application in simulator (i386 architecture). Your library must be fat library that supports arm and i386. With lipo tool you can make fat library from arm and i386 version. Reed here about it:

http://mark.aufflick.com/blog/2010/11/19/making-a-fat-static-library-for-ios-device-and-simulator

Vitaly Berg
  • 875
  • 8
  • 10
  • I have connected my phone to the Laptoop and have started compiling against it. its still giving me error. now i feel it has something to do with linking itself rather than architecture – Titus Apr 13 '13 at 17:06