简体   繁体   中英

Compiling Apple frameworks for simple command line programs

I have a simple program written in C and Objective-C. It consists of a few files that sit on my desktop which I compile from terminal using this:

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

I want to generate an audio file with my code and to do this need the AudioToolbox framework which I include in the .h file using

#import <AudioToolbox/AudioToolbox.h>

When I compile I get this error:

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

Ignore the error on line 61 which I believe is a separate issue. The other errors seem to do with not being able to access the framework. How can I correct this?

您必须将AudioToolbox框架与-framework链接:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM