Reputation: 12149
I'm trying to learn to create and use static libraries in my Xcode projects using this example. However I keep geting this error:
ld: warning: ignoring file /Developer/MathTest/iCodeBlogsMathLibrary/libICodeMathUtils.a,
missing required architecture i386 in file
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_MathFunctions", referenced from:
objc-class-ref in MathTestViewController.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
What might I be missing?
Upvotes: 3
Views: 4717
Reputation: 81
In my case,
> Find the “Other Linker Flags” build setting. Add the flag -ObjC to this build setting’s value if it is not already present <<
Upvotes: 1
Reputation: 69047
You are seemingly building for the simulator, which corresponds to the i386 architecture, but you are only linking with an iphone (arm) library.
To solve this, you should compile your library libICodeMathUtils.a both for i386 and arm.
After lookng at the tutorial you followed: a better way of integrating a static library in your project is by defining a dependency. You can look at this S.O. article for Xcode 4, and to this one for Xcode 3 (steps are given in the question itself).
Another option you have is building your library separately for i386 (simulator) and arm (device) and then use the command line tool lipo
to make a fat library that you can link in your MathTest project. Check man lipo
to know hoy to use the tool.
EDIT: about your comment
My static library does not show in Target Dependencies !!
have you dragged the static library from the included project tree to the target? the steps for Xcode 3 are:
add the library project as an included project;
find the static library in the included project and drag it on to your main target, adding it as a linked framework;
finally, in your target info pane, you can add the dependency.
Xcode4 seems to be able to automatically figure out dependencies, provided the targets are added to the project Scheme. You can do so by executing: Edit Scheme -> Build -> and then adding targets from your workspace. See also this S.O. question.
Upvotes: 5