2011-09-12 31 views
6

मैंने हाल ही में अपने ओबीजे प्रोजेक्ट में एक सी ++ फ़ाइल आयात की है जिसे मैं उपयोग करना चाहता हूं। कक्षा में मैं इसका उपयोग करना चाहता हूं, मैं MyClass.m से MyClass.mm पर फ़ाइल नाम बदलता हूं।.mm रूपांतरण आर्किटेक्चर i386 त्रुटियों के लिए अपरिभाषित प्रतीकों का कारण बनता है

ऐसा करने से मुझे 20 या तो त्रुटियां मिलती हैं। इन त्रुटियों को वास्तव में क्या करना है और मैं इन त्रुटियों को प्राप्त किए बिना, नई सी ++ कक्षा का उपयोग करने के लिए माई क्लास को एक उद्देश्य सी ++ कक्षा में कैसे बदल सकता हूं?

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

आपके कार्यों की तरह लगता है कि सी लिंकेज है, लेकिन आपने इसे अपने शीर्षलेख में ठीक से घोषित नहीं किया है। तो एक। एमएम फ़ाइल (उद्देश्य-सी ++) उन्हें देखने जा रही है और सी ++ लिंकेज मान लेती है। अच्छी तरह से __BEGIN_DECLS नाम है,

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

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

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

एप्पल मैक्रो इस के लिए उपयोग करता है:

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

एक बेहतर समाधान है कि शीर्ष लेख के भीतर ही करना है: सबसे आसान ठीक उचित extern ब्लॉक में है कि #include बयान रैप करने के लिए है और __END_DECLS लेकिन वे गैर मानक हैं ताकि आप प्लेटफ़ॉर्म पर साझा की गई फ़ाइलों में सीधे उनका उपयोग न कर सकें।

+0

धन्यवाद। इस उत्तर में आपने जो कुछ भी पोस्ट किया है वह मेरे लिए नया है – dubbeat

+0

आपको इसका उपयोग शुरू करने से पहले सी ++ पर पढ़ना चाहिए। यदि आप उन्हें गलत समझते हैं तो इस तरह की चीजें बाद में आपको काटने के लिए वापस आ सकती हैं। –

संबंधित मुद्दे