移植alsa-lib遇到的问题

linux audio    alsa lib    VERSIONED_SYMBOLS

这两天移植alsa lib时遇到了一个问题,被困住了好久。

做个记录,以后再被相同问题困住。

问题背景是这种。有个项目,客户要求使用新的alsa-lib库。

到alsa官网上看了下。最新的是1.0.28。

既然能够要用新的。咱们就彻底满足客户,用个最新的。

接下来看看遇到了什么问题。

事实上项目中曾经也有alsa lib库,毕竟alsa是眼下linux系统普遍採用的音频架构。

移植起来事实上也没什么麻烦的。

首先,代码搞过来。

然后。运行configure,来生成一堆东东,当中最重要的一个是config.h文件。

一般linux下,应用程序或应用层的库文件。接下来就是make 和make install。

因为我们系统中有自己的make 脚本,所以这两步被我们自己的make 命令所替代。

第一个遇到的问题是:

externals/alsa-lib/src/alisp/alisp.c: In function 'obj_type_str':

externals/alsa-lib/src/alisp/alisp.c:1028:1: error: control reaches end of non-void function [-Werror=return-type]

看错误提示能够知道。这是一个类型非void的函数没有返回值。

可是从[-Werror=return-type]可知,这事实上是一个 warning,仅仅是被作为error对待了。

为什么会被作为error对待,由于有-Werror=return-type的配置。

在locl compile flag中,增加-Wno-error=return-type。问题解决。

上面这个问题非常快被消灭。以下这个问题则费了我不是血。

问题提示:

/ld: failed to set dynamic section sizes: Bad value

编译是我的弱项。一见到编译问题,就感觉束手无策。

事实上万果皆有因。没有无缘无故的错误。

先看了下error之前的编译log,没发现实用的信息。

接下来找度娘帮忙。

也有人遇到过类似问题。看到的一个该问题的解决方式是,其代码中有个函数声明了但没定义,导致了该问题,加上该函数定义,问题解决。

alsa lib的代码不是我写的。有没有声明了但没定义的函数。我也不知道。

alsa lib库的代码量也非常可观,检查一遍仅仅能是想想而已。

检查编译log,发现開始有非常多warning提示一些宏反复定义了。

通过#ifndef,将这些warning解决。

编译还是有相同的问题。

编译log中另一些函数參数未被使用的warning,找到这些函数看了下,没发现函数实现有哪个函数没定义(相应前面网上的解决方式)。

是不是在configure的时候有些參数指定的不正确,导致有问题?

网上搜了搜别人的移植案例,没发现与我的配置不一致的地方。

既然configure的一个重要功能是生成config.h文件。那就比較下新生成的config.h文件与之去workable版本号的config.h文件有什么差别。

比較发现,还是有不少差别。

先用旧的config.h替换过来。

make。通过了!



肯定是config.h的问题了。

通过逐类排除,最后发现新的config.h中多了个下面定义:

/* compiled with versioned symbols */

#define VERSIONED_SYMBOLS /**/

把该定义删除,编译就ok了。

用百度搜索该宏,发现有人已经遇到过相同的问题(度娘还是有两下子的):

http://www.android100.org/html/201409/16/65158.html

看到该定义,想起来编译错误之前有一句提示:

libasound.so: version node not found for symbol snd_ctl_elem_info_get_dimension@@ALSA_0.9.3

只是,度娘也仅仅有两下子。

想看看VERSIONED_SYMBOLS的说明,还得靠谷歌。

http://infocenter.arm.com/help/index.jsp?

topic=/com.arm.doc.dui0206j/Beijfhhg.html

You can add specially-named symbols to input objects that cause the linker to create symbol versions. These symbols are of the form:

name@version for a non-default version of a symbol

name@@version for a default version of a symbol.

You must define these symbols, at the address of the function or data, as that you want to export. The symbol name is divided into two parts, a symbol name name and a version definition version. The name is added to the dynamic symbol table and becomes part
of the interface to the shared object. Version creates a version called ver if it does not already exist and associates name with the version called ver.

For more information on how to create version symbols, see:

Adding symbol versions in the Compiler User Guide

Chapter 2 Writing ARM Assembly Language in the Assembler Guide.

Example 4.6 places the symbols foo@ver1,foo@@ver2, and
bar@@ver1 into the object symbol table:

Example 4.6. Creating versioned symbols, embedded symbols

int old_function(void) __asm__("foo@ver1");

int new_function(void) __asm__("foo@@ver2");

int other_function(void) __asm__("bar@@ver1");

The linker reads these symbols and creates version definitions ver1 and ver2. The symbol foo is associated with a non-default version of ver1, and with a default version of ver2. The symbol bar is associated with a default version of ver1.

预计alsa lib中并未定义foo@ver1foo@@ver2类似的东东,所以出现了前面的错误。

解决的方法即删除:

#define VERSIONED_SYMBOLS

There is no way to create associations between versions with this method.

最新文章

  1. python学习之day1-基础知识
  2. 房地产行业的商业智能BusinessIntelligence介绍
  3. Angular自定义指令(directive)
  4. mysql设置远程访问权限
  5. String类的compareTo()方法的源码解析
  6. CSS盒子模型元素实际宽度的计算
  7. Sql Server 2012 Enterprise Edition 企业版 迅雷 下载地址
  8. javascript类型注意事项
  9. ionic导航之后返回功能的说明
  10. 0001-Weekly Meeting on 13th and 20th March, 2015
  11. Android--PullToRefreshListView 的简单使用
  12. 各个浏览器下实现Ajax的JS
  13. Phonegap(Cordova)3.4 + Android 环境搭建
  14. Sftp和ftp 差别、工作原理等(汇总ing)
  15. linux下的外网木马前期要的工具
  16. C#中的out参数/ref参数/params可变参数
  17. 删除Docker镜像
  18. 【rabbitmq】RabbitMQ 集群与网络分区
  19. Groovy语言学习--语法基础(2)
  20. 怎样删除windows server back 备份副本文件

热门文章

  1. HDU - 1705 Count the grid
  2. 视频播放插件Video.js
  3. struts拦截器详解
  4. 利用hibernate与struts框架制作简单注册界面
  5. 【Luogu】P2536病毒检测(Trie上DP)
  6. kb-09-线段树--区间合并比较繁
  7. 洛谷P4175 - [CTSC2008]网络管理
  8. samba安装和配置
  9. YY的GCD(bzoj 2820)
  10. 页面之间传值的方法asp