Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.mm转换导致架构i386错误的未定义符号 我最近将一个C++文件导入到我想使用的OBJ项目中。在我想在中使用它的类中,我将文件名从MyClass.m更改为MyClass.mm_C++_Objective C - Fatal编程技术网

.mm转换导致架构i386错误的未定义符号 我最近将一个C++文件导入到我想使用的OBJ项目中。在我想在中使用它的类中,我将文件名从MyClass.m更改为MyClass.mm

.mm转换导致架构i386错误的未定义符号 我最近将一个C++文件导入到我想使用的OBJ项目中。在我想在中使用它的类中,我将文件名从MyClass.m更改为MyClass.mm,c++,objective-c,C++,Objective C,这样做会给我20个左右的错误。这些错误到底意味着什么,我如何将MyClass更改为目标C++类,以方便我使用的新C++类,而不必得到这些错误? Undefined symbols for architecture i386: "setAudioInputIsStereo(audiosourceobj*, bool)", referenced from: -[Engine extractMp3Audio:withChannelId:withPadId:] in Engine.o

这样做会给我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

听起来你的函数有C链接,但你还没有在它们的头中正确声明。所以.mm文件(Objul-C++)将看到它们并假设C++链接。最简单的修复方法是将
#include
语句包装到相应的
外部
块中:

extern "C" {
    #include "..."
}
更好的解决方案是在标头本身内执行此操作:

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

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

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

苹果为此使用了宏,它们的名字很好地命名为
\uu BEGIN\u DECLS
\uu END\u DECLS
,但它们是非标准的,所以您不能在跨平台共享的文件中直接使用它们。

谢谢。你在这个答案中所发布的所有东西都是全新的,你应该在开始使用C++之前先阅读C++。如果你弄错了,这类事情可能会回来咬你。