2011-09-12 6 views
6

私は最近、使用したいobjプロジェクトにC++ファイルをインポートしました。私が使用したいクラスでは、ファイル名をMyClass.mからMyClass.mmに変更します。.mm変換によりアーキテクチャi386エラーの未定義シンボルが発生する

これを行うと、20回ほどエラーが発生します。これらのエラーはどういう意味ですか、また、これらのエラーが発生することなく、MyClassを目的のC++クラスに変更して、使用したい新しいC++クラスを容易にする方法はありますか?

Undefined symbols for architecture i386: 
    "setAudioInputIsStereo(audiosourceobj*, bool)", referenced from: 
     -[Engine extractMp3Audio:withChannelId:withPadId:] in Engine.o 
    "setAudioInputFrameCount(audiosourceobj*, int)", referenced from: 
     -[Engine extractMp3Audio:withChannelId:withPadId:] in Engine.o 
    "setAudioInputSendValue(audiosourceobj*, int)", referenced from: 
     -[Engine extractMp3Audio:withChannelId:withPadId:] in Engine.o 
    "getPointerToAudioLeftBuffer(audiosourceobj*)", referenced from: 
     -[Engine extractMp3Audio:withChannelId:withPadId:] in Engine.o 
    "getPointerToAudioRightBuffer(audiosourceobj*)", referenced from: 
     -[Engine extractMp3Audio:withChannelId:withPadId:] in Engine.o 
    "freeAudioBuffers(audiosourceobj*)", referenced from: 
     -[Engine extractMp3Audio:withChannelId:withPadId:] in Engine.o 
     -[Engine clearAudioInput:pid:] in Engine.o 
     -[Engine reset] in Engine.o 
    "setAudioInputReadPoint(audiosourceobj*, int)", referenced from: 
     -[Engine extractMp3Audio:withChannelId:withPadId:] in Engine.o 
    "setAudioInputHasAudio(audiosourceobj*, bool)", referenced from: 
     -[Engine extractMp3Audio:withChannelId:withPadId:] in Engine.o 
     -[Engine reset] in Engine.o 
     -[Engine setAudioPath:channel:pad:] in Engine.o 
    "setAudioInputState(audiosourceobj*, int)", referenced from: 
     -[Engine extractMp3Audio:withChannelId:withPadId:] in Engine.o 
     -[Engine clearAudioInput:pid:] in Engine.o 
     -[Engine reset] in Engine.o 
     -[Engine setAudioPath:channel:pad:] in Engine.o 
    "initAudioInputHasAudio(audiosourceobj*, signed char)", referenced from: 
     -[Engine clearAudioInput:pid:] in Engine.o 
     -[Engine reset] in Engine.o 
    "initAudioInputReadPoint(audiosourceobj*, int)", referenced from: 
     -[Engine clearAudioInput:pid:] in Engine.o 
     -[Engine reset] in Engine.o 
    "initAudioInputFrameCount(audiosourceobj*, int)", referenced from: 
     -[Engine clearAudioInput:pid:] in Engine.o 
     -[Engine reset] in Engine.o 
    "initAudioInputSampleToAction(audiosourceobj*, int)", referenced from: 
     -[Engine clearAudioInput:pid:] in Engine.o 
     -[Engine reset] in Engine.o 
    "newChannelOBJ()", referenced from: 
     setUpChannels(int, int)in Engine.o 
    "setVolume(channelobj*, float)", referenced from: 
     setUpChannels(int, int)in Engine.o 
    "setMute(channelobj*, int)", referenced from: 
     setUpChannels(int, int)in Engine.o 
    "setNumberOfInputs(channelobj*, int)", referenced from: 
     setUpChannels(int, int)in Engine.o 
    "setChannelID(channelobj*, int)", referenced from: 
     setUpChannels(int, int)in Engine.o 
    "createInputs(channelobj*, int)", referenced from: 
     setUpChannels(int, int)in Engine.o 
    "setBufferSize(channelobj*, float)", referenced from: 
     setUpChannels(int, int)in Engine.o 
    "createChannelEQS(channelobj*)", referenced from: 
     setUpChannels(int, int)in Engine.o 
    "actionupdatecomplete(audiosourceobj*, objc_object*)", referenced from: 
     channelMixerCallback(void*, unsigned long*, AudioTimeStamp const*, unsigned long, unsigned long, AudioBufferList*)in Engine.o 

答えて

19

あなたの関数のようなサウンドはCリンケージを持っていますが、ヘッダーに適切に宣言していません。したがって、.mmファイル(Objective-C++)はそれらを見て、C++リンケージを想定しています。

extern "C" { 
    #include "..." 
} 

より良い解決策は、ヘッダ自体の中にあることを行うことです:最も簡単な修正は、適切なexternブロック内#include文があることラップすることです

#if defined(__cplusplus) 
    extern "C" { 
#endif /* defined(__cplusplus) */ 

extern void whatever(void); 
extern int foobar(double); 
... 

#if defined(__cplusplus) 
    } 
#endif /* defined(__cplusplus) */ 

Appleがうまく名付けられ、このためのマクロを使用しています__BEGIN_DECLS__END_DECLSしかし、それらは非標準的なので、プラットフォーム間で共有されているファイルで直接使用することはできません。

+0

ありがとうございました。あなたがこの答えに投稿したものはすべて私にとってまったく新しいものです – dubbeat

+0

あなたはC++を使い始める前にそれを使い始めるべきです。このようなことは、あなたが間違ってしまうと後であなたを噛んで戻ってくることがあります。 –

関連する問題