Strange linker (ld) behavior, it sees only half of class's methods
I have 2 targets in XCode, an executable containing class Record like
class Record
{
public:
const char * getFirstName() const;
void setFirsttName(const char * firstName);
const char * getCompany() const;
void setCompany(const char * company);
...
}
And a unit test bundle, which is linked to executable via b开发者_C百科undleLoader and contains test like
...
Record record;
record.setFirsttName("aaa");
record.setCompany("bbb");
The strange and annoying thing is, I get a linker error saying that it doesnt see setCompany symbol, but it sees setFirsttName. Complete cleans and rebuilds dont help the matter. Can anyone help?
Edit 1:
It was DEAD_CODE_STRIPPING = YES. Aaargh!!!
Do you have a definition of setCompany
in your source file for Record
? What is in the header is just a declaration, and you need a definition to link programs that use the method.
Did you forget to define setCompany
in your source file? Alternately did you forget to qualify it with the ClassName::
so it's treated as a class method?
精彩评论