【发布时间】:2012-10-11 21:09:10
【问题描述】:
在我的静态库项目(target:sdk.a)中,我使用了这样的外部函数:
// in the PlatformUnity.h file
extern "C"{
extern UIView * UnityGetGLView();
extern UIViewController * UnityGetGLViewController();
}
// in the PlatformUnity.mm file (*.mm NOT the *.m)
UIView * funcA(){
return UnityGetGLView();
}
UIViewController * funcB(){
return UnityGetGLViewController();
}
在另一个名为 Unity-iPhone.xcodeproj 的项目中,我使用了 SDK.a 。 并且有一个名为 AppController.mm 的文件包含以下代码:
static UIViewController* sGLViewController = nil;
UIViewController* UnityGetGLViewController()
{
return sGLViewController;
}
static UIView* sGLView = nil;
UIView* UnityGetGLView()
{
return sGLView;
}
当我构建 Unity-iPhone.xcodeproj 时,它告诉我它找不到函数 UnityGetGLView()。以下链接错误:
Undefined symbols for architecture armv7:
"_UnityGetGLViewController", referenced from:_funcB in SDK.a(PlatformUnity.o)
"_UnityGetGLView", referenced from:_funcA in SDK.a(PlatformUnity.o)
这两个函数确实是在AppController.mm中定义的,但是为什么链接的时候找不到呢? Unity-iPhone.xcodeproj 的另一个链接器标志如下:
-all_load -weak_framework CoreMotion -weak-lSystem
【问题讨论】: