开发者

Strange linker (ld) behavior, it sees only half of class's methods

开发者 https://www.devze.com 2023-02-18 05:44 出处:网络
I have 2 targets in XCode, an executable containing class Record like class Record { public: const char * getFirstName() const;

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消