LazyLastBencher
LazyLastBencher

Reputation: 195

Static Library linking error. Undefined symbols for architecture armv7s

The error is..

Undefined symbols for architecture armv7s:
   "ABCD_Initialize(ABCD_data_type*)", referenced from:
       -[MyViewController doSomething] in MyViewController.o
   ld: symbol(s) not found for architecture armv7s
   clang: error: linker command failed with exit code 1 (use -v to see invocation)

I would like to list what all I've done

ABCD_Initialize is a function in header file of the static library i added.

  1. Checked almost every related question.
  2. Added all the files to target properly.
  3. Linked the FAT file (.a file) in the build phases
  4. lipo on FAT file says it is valid for armv6 armv7 and armv7s
  5. Set Build Active Architecture Only to YES.
  6. Added .h file related to the FAT file
  7. restarted Xcode, Mac etc :)

A few things about my app

  1. Created a workspace
  2. Added a few other dependent .xcodeproj files to the workspace.
  3. Added FAT file (of C++) and linked in build phases
  4. set -ObjC flag in Other Linker Flags (to Load all members of static archive libraries)

Environment specs

Mountain Lion + Xcode 4.6 + iOS SDK 6.1

Let me know if you need more information. Any help is appreciated.

Thanks

J0k3r

Upvotes: 2

Views: 2013

Answers (1)

Michael Dautermann
Michael Dautermann

Reputation: 89549

My initial answer:

I'd say step 5 is incorrect.

If you're building a library, you want to build for all architectures, not just the "active architecture".

Set that to "NO" and see how it goes.

My second answer:

Also, make certain you've added "extern "C" in your library function declarations:

#ifdef __cplusplus
extern "C" {
#endif

ABCD_Initialize(ABCD_data_type*);

#ifdef __cplusplus
}
#endif

which help with demangling the symbols when they are linked against your app. Here's a related question with a decent explanation of what's going on.

Upvotes: 5

Related Questions