如何解决Undefined Symbols错误? [英] How to resolve Undefined Symbols error?

查看:95
本文介绍了如何解决Undefined Symbols错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到此错误

Undefined symbols:
".objc_class_name_MyClass", referenced from:
  literal-pointer@__OBJC@__cls_refs@MyClass in infoViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

在引用以下静态方法时:

When referencing the static method below:

[MyClass ClickComment:self.navigationController];

MyClass是在我在我的应用程序项目中引用的静态库中定义的.当我开始键入"[MyClass" ...时,我得到消息提示.该应用程序项目知道MyClass存在以及在其上定义了哪些方法.但是,我得到了上面的错误.注释掉此调用使项目可以正确构建.

MyClass is defined in a static library that I'm referencing in my app project. When I start typing "[MyClass "..., I get message hints. The app project knows MyClass exist and which methods are defined on it. Yet, I get the above error. Commenting out this call allows the project to build without error.

在静态库中,我有一个.h文件,该文件引用了该库的所有.h文件.这样,应用程序项目仅需要引用静态库中的一个.h文件.静态库项目也有一个应用程序.我用它来测试静态库.我可以做上述的罚款.当静态库已构建设备/调试版本并且应用程序项目已构建模拟器/调试时,我通常会看到这些类型的错误.但是,两个版本都是同步的.

In the static library, I have a .h file that references all of the library's .h files. This way, the app project needs to reference only one .h file from the static library. The static library project also has an app. I use it to test the static library. I can do the above call fine. I usually see these types of errors when the static library has build a device/debug version and the app project has build simulator/debug. However, both builds are in sync.

我知道有一个参考问题,但不确定如何解决.有什么建议吗?

I know there is a reference issue but I'm unsure how to resolve it. Any suggestions?

推荐答案

这意味着在编译过程中找到了头文件,但是链接程序不知道静态库.确保您的静态库在项目视图的目标-> YourMainTarget>用库链接二进制文件"下列出.

That means that the header files are found during compilation, but the linker is not aware of the static library. Make sure your static library is listed under "Targets -> YourMainTarget > Link Binary with Libraries" in the project view.

请参见 http://developer.apple.com/tools/XCode/XCodeprojects.html

这篇关于如何解决Undefined Symbols错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆