【发布时间】:2013-09-25 14:13:43
【问题描述】:
我在我当前的 Xcode 4.6 项目中添加了一个 obj-c 类(.mm 和 2 个标头)。一个头文件具有调用 obj-c 类的原型,另一个定义 .mm 类。这是它的样子。
myinterface.h
#ifndef MYINTERFACE_H
#define MYINTERFACE_H
BOOL LaunchApp(CAtlString exePath);
#endif
myLaunchClass.h
#import "myinterface.h"
@interface myLaunchClass : NSObject
-(BOOL) LaunchApp:(CAtlString)exePath;
@end
myLaunchClass.mm
@import "myLaunchClass.h"
@implementation myLaunchClass
-(BOOL) LaunchApp:(CAtlString)exePath
{
....
return someCondition;
}
@end
从那里编译好。我在 Build Phases 中将 .mm 文件添加到 Target 中,并将 header 位置添加到 Build Settings 中的 Header Search Paths 中。
当我在 .cpp 文件 (#include "myinterface.h") 中包含头文件时,我没有任何错误。但是,当我调用我的函数 (::LaunchApp(exePath);) 时,出现链接器错误。
错误
Undefined symbols for architecture i386:
"LaunchApp(CAtlString)", referenced from:
myCppFile::myCppFunction() const in myCppFile.o
ld: symbol(s) not found for architecture i386
有什么想法吗?我认为这对于 Mac 开发人员来说一定是一个明显的错误,但我对 Mac 编程还是有点陌生。任何帮助表示赞赏。
【问题讨论】:
标签: c++ objective-c linker osx-lion xcode4.6