博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
移植alsa-lib遇到的问题
阅读量:7238 次
发布时间:2019-06-29

本文共 3146 字,大约阅读时间需要 10 分钟。

移植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了。
用百度搜索该宏,发现有人已经遇到过相同的问题(度娘还是有两下子的):
看到该定义,想起来编译错误之前有一句提示:
libasound.so: version node not found for symbol

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

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

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:

for a non-default version of a symbol
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 ,, and into the object symbol table:

Example 4.6. Creating versioned symbols, embedded symbols

int old_function(void) __asm__("");

int new_function(void) __asm__("");
int other_function(void) __asm__("");

 

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中并未定义和类似的东东,所以出现了前面的错误。

解决的方法即删除:

#define VERSIONED_SYMBOLS

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

 

转载地址:http://brofm.baihongyu.com/

你可能感兴趣的文章
对ASP.NET网站高性能和多并发的设计的讨论
查看>>
组策略之账户安全设置
查看>>
[Unity3d]打包Assetbundle并加载
查看>>
使用我们的DataProvider
查看>>
抓信插件开发遇到网页的CSS不起作用
查看>>
体验microsoft Security Essentials(微软免费杀毒软件)
查看>>
解决Ubuntu中更改MySQL默认编码报错
查看>>
VLAN概念的面试题及解答_路由交换
查看>>
mysql忧化参数
查看>>
深入浅出单实例Singleton设计模式
查看>>
Windows Phone 实用开发技巧(12):让你的Windows Phone应用变得更Metro
查看>>
极速理解设计模式系列:6.适配器模式(Adapter Pattern)
查看>>
Swing与Servlet通信简单示例
查看>>
【一天一个shell命令】文本操作系列-chmod
查看>>
Cisco 3550-SMI IOS升级过程分享
查看>>
Silverlight实用窍门系列:61.Silverlight中的Trigger触发器,自定义翻页触发器
查看>>
JSF Spring Hibernate 整合:JSH1
查看>>
【移动开发】Android中不用图片资源也能做出好看的界面
查看>>
第二章 深入探讨控制反转(Ioc)和依赖注入(DI)之二
查看>>
删除Windows自带游戏
查看>>