移植alsa-lib遇到的問題,移植alsa-lib遇到

來源:互聯網
上載者:User

移植alsa-lib遇到的問題,移植alsa-lib遇到

移植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的說明,還得靠Google。
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, andbar@@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@ver1和foo@@ver2類似的東東,所以出現了前面的錯誤。

解決辦法即刪除:
#define VERSIONED_SYMBOLS

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

 


移植newlib的問題

先嘗試直接簡單修改配置編譯 如果有合適的配置這樣當然最省事
有如果有問題了在考慮完全移植的問題
 
linux核心移植編譯時間遇到的問題

錯誤原因是沒有交叉編譯器arm-linux-gcc。 這個交叉編譯器是基於gcc的,一般選用4.1版本的gcc,這個版本對於文法要求不是那麼高,編譯不會經常出錯,交叉編譯器的具體的製作過程幾句話說不清,網路上的資料很多,可以自己找找。
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.