Link errors: symbol(s) not found(转)

今天在编写《iphone3开发教程》中第七章的内容时,突然被一个错误搞晕了,改了好多地方都没成功,后来想在网上查查,结果还都是英文!庆幸的是,读懂了某一篇段,还真改正了过来,链接无误。下面和大家分享一下吧!

错误源:在试图控制器中,想应用 AudioToolbox类中的函数AudioServicesCreateSystemSoundID输出声音,虽然已添加了头文件,但是链接时却出现了错误:

Ld build/Debug-iphonesimulator/Pickers.app/Pickers normal i386

cd /Users/wang/Documents/Pickers

setenv MACOSX_DEPLOYMENT_TARGET 10.6

setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"

/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk -L/Users/wang/Documents/Pickers/build/Debug-iphonesimulator -F/Users/wang/Documents/Pickers/build/Debug-iphonesimulator -filelist /Users/wang/Documents/Pickers/build/Pickers.build/Debug-iphonesimulator/Pickers.build/Objects-normal/i386/Pickers.LinkFileList -mmacosx-version-min=10.6 -framework Foundation -framework UIKit -framework CoreGraphics -o /Users/wang/Documents/Pickers/build/Debug-iphonesimulator/Pickers.app/Pickers

 

Undefined symbols:

  "_AudioServicesCreateSystemSoundID", referenced from:

      -[SingleController playwithSound] in SingleController.o

      -[SingleController spin] in SingleController.o

  "_AudioServicesPlaySystemSound", referenced from:

      -[SingleController playwithSound] in SingleController.o

      -[SingleController spin] in SingleController.o

ld: symbol(s) not found

collect2: ld returned 1 exit status

 

看到这么长的错误,虚了吧?不用害怕,其实解决的办法很简单!AudioToolbox不属于uikit框架,我们必须把项目链接到调用的函数所属于的框架中。在xcode左侧的group&files列表中,右击framworks文件,选择exiting frameworks,选择AudioToolbox.framworks之后再编译运行就没错了。


 下面简单说一下FrameWork。它是一些类的集合,通常是一些可能一起使用的类集合.换句话说,这些类被一起编译成可复用的代码库(library of code)。所有相关的资源和代码库一起放入一个带扩展名“.framework”的目录(Mac OSX bundle 的概念可以参考苹果的一些文档). 系统自带的framework可以在/System/Library/Frameworks找到. 几个基本的framworks:

 

          1. Foundation: 所有的面向对象语言都会有一些标准结构: value , collection , String, dates, lists, thread等等.所有的这些都在Foundation framework里面(可以对比C++的STL)

          2. Appkit: 所有和用户界面相关的类都在这里. Windows,buttons,text field, event, drawing. 它还有个名字: ApplicationKit

          3. Core Data: Core Data可以方便的让你把你的对象存储成文件,或是从文件中加载你的对象.

              供稿者  sunshine

 

 

转自:  http://hi.baidu.com/herozoo/blog/item/2603653caef8c5d69f3d6231.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值