0

I've recently been building a Mac OS X application that utilizes the Core Audio framework to play back a sequence of rendered tones.

As such, I've imported the following files:

#import "songComponents.h"
#import "MusicBoxViewController.h"
#import <AudioToolbox/AudioToolbox.h>
#import <AudioUnit/AudioUnit.h>
#import <AudioUnit/AUComponent.h>
#import <AudioUnit/AudioComponent.h>
#import <assert.h>

Interestingly, though, I've received the following error messages:

    Undefined symbols for architecture x86_64:
  "_AudioComponentFindNext", referenced from:
      -[songComponents synthesizeSong] in songComponents.o
  "_AudioComponentInstanceNew", referenced from:
      -[songComponents synthesizeSong] in songComponents.o
  "_AudioUnitSetProperty", referenced from:
      -[songComponents synthesizeSong] in songComponents.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

These functions are clearly defined in their header files. Because they are part of the core framework, does anyone know if there is a specific way I have to import core files to make this work? Or is there another reason they might not be working?

(As an add-on: my current operating system is 10.7.5 OS X, and XCode is v4.6. I'm adapting this project from some code I found that was written for an iOS project in a circa-2011 version of XCode. I cannot find what I am doing differently.)

Dubbrack
  • 27
  • 1
  • 7
  • 1
    As an aside, if you're using Xcode 5+ I recommend you start using the new `@import` syntax which will mean you never have this problem again. See this SO answer for more info: http://stackoverflow.com/q/18947516/558933 – Robotic Cat Nov 17 '13 at 08:48
  • Thanks! I haven't upgraded my operating system, so I can't get the new XCode, but when I do I'll check it out. – Dubbrack Nov 17 '13 at 18:08

1 Answers1

1

The definition of these function in header files has nothing to do with the linker.

The header just provide to the compiler the signatures of what's available. Then the linker must have the corresponding binary library available to link your calls to the library it self, this is done by statically linking the library (physically link together your binary and the library) or dynamically (your calls to the library are correctly relocated to the entry points in the library itself)

To do this you just need to add the corresponding frameworks to your projects:

enter image description here

Jack
  • 131,802
  • 30
  • 241
  • 343
  • 1
    Thank you so much! That solved my problem! For anyone else who reads this, the two frameworks I needed were AudioUnit.framework and AudioToolbox.framework. – Dubbrack Nov 17 '13 at 03:11