------------ The following is the contents of the file ------------------
Fraction.h# Import
@ Interface Fraction: NSObject
- (Void) print;
- (Double) convertToNum;
- (Void) setTo: (int) n Over: (int) d;
- (Void) reduce;
@ Property int numerator, denominator;
@ End
------------ The following is the contents of the file ------------------
Fraction.m# Import "Fraction.h"
@ Implementation Fraction
{
}
@ Synthesize numerator, denominator;
- (Fraction *) initWith: (int) n over: (int) d {
/ / Implementation omitted
}
- (Void) reduce {
/ / Implementation omitted
}
- (Void) print {
/ / Implementation omitted
}
- (Double) convertToNum {
/ / Implementation omitted
}
- (Void) setTo: (int) n Over: (int) d {
/ / Implementation omitted
}
@ End
------------- The following is a Fraction + Ops.h content -------------
# Import "Fraction.h"
@ Interface Fraction (MathOps)
- (Fraction *) add: (Fraction *) f;
- (Fraction *) mul: (Fraction *) f;
- (Fraction *) sub: (Fraction *) f;
- (Fraction *) div: (Fraction *) f;
@ End
---------- The following is the content of Fraction + Ops.m -------------
# Import "Fraction + MathOps.h"
# Import "Fraction.m"
@ Implementation Fraction (MathOps)
- (Fraction *) add: (Fraction *) f {
/ / Implementation omitted
}
- (Fraction *) sub: (Fraction *) f {
/ / Implementation omitted
}
- (Fraction *) mul: (Fraction *) f {
/ / Implementation omitted
}
- (Fraction *) div: (Fraction *) f {
/ / Implementation omitted
}
@ End
The problem now is that the implementation of the code have been identified without error, but the compiler when prompted compilation fails. Error message as follows:
Ld / Users / czclk / Library / Developer / Xcode / DerivedData / HelloWorld-bptlkzckpfrvvkdgxolkkdxzrthb / Build / Products / Debug / HelloWorld normal x86_64
cd / Users / czclk / Desktop / HelloWorld / HelloWorld
setenv MACOSX_DEPLOYMENT_TARGET 10.8
/ Applications / Xcode.app / Contents / Developer / Toolchains / XcodeDefault.xctoolchain / usr / bin / clang-arch x86_64-isysroot / Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10. 8.sdk -L/Users/czclk/Library/Developer/Xcode/DerivedData/HelloWorld-bptlkzckpfrvvkdgxolkkdxzrthb/Build/Products/Debug -F/Users/czclk/Library/Developer/Xcode/DerivedData/HelloWorld-bptlkzckpfrvvkdgxolkkdxzrthb/Build/Products / Debug-filelist / Users/czclk/Library/Developer/Xcode/DerivedData/HelloWorld-bptlkzckpfrvvkdgxolkkdxzrthb/Build/Intermediates/HelloWorld.build/Debug/HelloWorld.build/Objects-normal/x86_64/HelloWorld.LinkFileList-mmacosx-version-min = 10.8-fobjc-arc-framework Foundation-o / Users / czclk / Library / Developer / Xcode / DerivedData / HelloWorld-bptlkzckpfrvvkdgxolkkdxzrthb / Build / Products / Debug / HelloWorld
duplicate symbol _OBJC_IVAR_ $ _Fraction.numerator in:
/ Users/czclk/Library/Developer/Xcode/DerivedData/HelloWorld-bptlkzckpfrvvkdgxolkkdxzrthb/Build/Intermediates/HelloWorld.build/Debug/HelloWorld.build/Objects-normal/x86_64/Fraction.o
/ Users/czclk/Library/Developer/Xcode/DerivedData/HelloWorld-bptlkzckpfrvvkdgxolkkdxzrthb/Build/Intermediates/HelloWorld.build/Debug/HelloWorld.build/Objects-normal/x86_64/Fraction + MathOps.o
duplicate symbol _OBJC_IVAR_ $ _Fraction.denominator in:
/ Users/czclk/Library/Developer/Xcode/DerivedData/HelloWorld-bptlkzckpfrvvkdgxolkkdxzrthb/Build/Intermediates/HelloWorld.build/Debug/HelloWorld.build/Objects-normal/x86_64/Fraction.o
/ Users/czclk/Library/Developer/Xcode/DerivedData/HelloWorld-bptlkzckpfrvvkdgxolkkdxzrthb/Build/Intermediates/HelloWorld.build/Debug/HelloWorld.build/Objects-normal/x86_64/Fraction + MathOps.o
duplicate symbol _OBJC_CLASS_ $ _Fraction in:
/ Users/czclk/Library/Developer/Xcode/DerivedData/HelloWorld-bptlkzckpfrvvkdgxolkkdxzrthb/Build/Intermediates/HelloWorld.build/Debug/HelloWorld.build/Objects-normal/x86_64/Fraction.o
/ Users/czclk/Library/Developer/Xcode/DerivedData/HelloWorld-bptlkzckpfrvvkdgxolkkdxzrthb/Build/Intermediates/HelloWorld.build/Debug/HelloWorld.build/Objects-normal/x86_64/Fraction + MathOps.o
duplicate symbol _OBJC_METACLASS_ $ _Fraction in:
/ Users/czclk/Library/Developer/Xcode/DerivedData/HelloWorld-bptlkzckpfrvvkdgxolkkdxzrthb/Build/Intermediates/HelloWorld.build/Debug/HelloWorld.build/Objects-normal/x86_64/Fraction.o
/ Users/czclk/Library/Developer/Xcode/DerivedData/HelloWorld-bptlkzckpfrvvkdgxolkkdxzrthb/Build/Intermediates/HelloWorld.build/Debug/HelloWorld.build/Objects-normal/x86_64/Fraction + MathOps.o
ld: 4 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use-v to see invocation)
Ask the experts how to solve the problem where it? Thank you! ! ! !
Reply:
Guiqiu expert to solve! ! ,!
Reply:
The problem is: # import "Fraction.m"
Please do not import. M
Reply:
If you do not import it, I can not reference class Fraction in the property or method in Fraction + MathOps.m years, how can this be done?
Reply:
. H ah. H ah. H ah. H ah. H ah. H ah
Reply:
Find expert answers! ! ! Thank you
Reply:
? You tried it
Reply:
By doing the task treasure
Reply:
Ah, have you tried it?
Reply:
You can put Fraction Inside you want to refer to the definition of things. H inside references. H file, rarely cited. M file
Reply:
I think the lack of libraries,,,,
framworks add needed
Reply:
The problem is: # import "Fraction.m", not the introduction of m documents, use the words, references to the class header file, BaseController * temp = [[BaseController alloc] method: @ ""];
Reply:
Waiting for the emergence of an expert to answer
Reply:
I have encountered this problem, I do not know LZ not solve the key is not to import Fraction.m then there can not be referenced in the instance Fraction interface declaration, ah? ? ? ?
Reply:
This post was quite festive -
Reply:
Good to learn about grammar, simply take the book, according to write a class has so complicated?
Reply:
Reply:
Ah landlord, the landlord, what I might finally clear,
/ / Fraction class
@ Interface Fraction: NSObject
{
int numerator, denominator ;/ / is this step ~ ~ ~ ~ finished on ok ~ ~ ~
}
@ Property int numerator, denominator;
- (Void) print;
- (Void) setTo: (int) n over: (int) d;
- (Double) convertToNum;
- (Void) reduce;
@ End
Reply:
# Import problem. . .
Reply:
Try to find other linker flags in the build settings and add-ObjC-all_load
And then re-build your project.
Reply:
# Import problem ah, brother == how the header file to the source files gone
No comments:
Post a Comment