为简单的命令行程序编译Apple框架

时间:2012-02-01 17:49:06

标签: objective-c c command-line terminal

我有一个用C和Objective-C编写的简单程序。它由我在桌面上的几个文件组成,我使用这个文件从终端编译:

gcc -framework Foundation audio.m WavReader.m WavFileCreator.m -o audio

我想用我的代码生成一个音频文件,为此需要使用我在.h文件中包含的AudioToolbox框架

#import <AudioToolbox/AudioToolbox.h>

编译时我收到此错误:

WavFileCreator.m: In function ‘createNewWAV’:
WavFileCreator.m:61: warning: initialization makes integer from pointer without a cast
Undefined symbols for architecture x86_64:
  "_AudioFileCreateWithURL", referenced from:
      _createNewWAV in cckeb4pu.o
  "_AudioFileWriteBytes", referenced from:
      _createNewWAV in cckeb4pu.o
  "_AudioFileClose", referenced from:
      _createNewWAV in cckeb4pu.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

忽略第61行的错误,我认为这是一个单独的问题。其他错误似乎与无法访问框架有关。我怎么能纠正这个?

1 个答案:

答案 0 :(得分:4)

您必须将AudioToolbox框架与-framework

相关联
$ gcc -framework Foundation -framework AudioToolbox audio.m WavReader.m WavFileCreator.m -o audio