zoukankan      html  css  js  c++  java
  • Undefined symbols for architecture i386: "MyGetOpenALAudioData(__CFURL const*, int*, int*, int*)"

    今天把apple developer上的例子程序oalTouch中的MyOpenALSupport.h和MyOpenALSupport.c添加到自己的工程中,并在另一个文件xxx.cpp里调用,结果出现报错:

    Undefined symbols for architecture i386:

      "MyGetOpenALAudioData(__CFURL const*, int*, int*, int*)", referenced from:

          Cc3dALBuffer::initBuffer(std::string const&, void*&, unsigned int&) in c3dALBuffer.o

      "alBufferDataStaticProc(int, int, void*, int, int)", referenced from:

          Cc3dALBuffer::initBuffer(std::string const&, void*&, unsigned int&) in c3dALBuffer.o

    ld: symbol(s) not found for architecture i386

    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    起初不解。后搜索到下帖:

    http://www.idevgames.com/forums/printthread.php?tid=8148

    才明白,原来c++调用.c文件中的函数是需要使用extern "C"的。

    于是在xxx.h中加入以下代码:

    extern"C" {

        #include"MyOpenALSupport.h"

    };

    问题就解决了。

    ----补充:

    在自己的项目中使用oalTouch中的MyOpenALSupport.h和MyOpenALSupport.c,结果发现某些音效会带有兹兹的杂音。但改用MusicCube例子程中的MyOpenALSupport.h就不会出现问题,对比了一下,发现oalTouch和MusicCube两个例子中的MyGetOpenALAudioData函数的实现却实有差别,那么只能认为oalTouch中MyGetOpenALAudioData的实现有bug了。

    注,改用MusicCube中的MyOpenALSupport.h。起初编译不过,MyGetOpenALAudioData中的goto Exit语句报"goto into protected scope"的错误。于是把MusicCube中的MyOpenALSupport.h也拆成MyOpenALSupport.h和MyOpenALSupport.c两个文件,然后就可以编译通过了。

  • 相关阅读:
    yii 验证码功能的实现
    关于php优化 你必须知道的一些事情
    php实现两分法查找
    Python封装的访问MySQL数据库的类及DEMO
    新学习的Python的代码(while循环)
    基于位运算符的IP和数值转换
    JS数组操作常用方法
    JS输出日历
    PHP程序输出日历
    PHP中计算时间差(上周,上月,去年,昨天等)
  • 原文地址:https://www.cnblogs.com/wantnon/p/3575764.html
Copyright © 2011-2022 走看看