交叉編譯libX11

2021-06-27 17:53:36 字數 4178 閱讀 9118

本文探索如何將libx11移植到arm開發板。

新建乙個src目錄,並且將原始碼解壓到其中:

mkdir src

tar axvf libx11-1.5.0.tar.bz2 -c src

建立乙個用於目錄作為libx11的安裝位置(因為是交叉編譯,所以不能使用預設的安裝目錄,否則會破壞ubuntu系統):

mkdir libx11_install
為了方便配置,可以先設定環境變數(具體值要根據你的目錄名和交叉工具鏈名進行修改):

export prefix=/home/liyihai/downloads/libx11_install

export host=arm-arago-linux-gnueabi

將上述內容儲存為env.sh,然後執行以下命令使其生效:

source env.sh
進入libx11-1.5.0目錄,執行下面命令進行配置

./configure --prefix=$prefix --host=$host
配置結果如下:

x11 will be built with the following settings:

loadable i18n module support: no

loadable xcursor library support: yes

threading support: yes

use threads safe api: yes

threads stubs in libx11: no

xcms: yes

internationalization support: yes

xf86bigfont support: no

xkb support: yes

xlocaledir environment variable support: yes

compose table cache enabled: no

functional specs building enabled: yes

後來在配置libx11-1.6.12時遇到下面錯誤

可通過--cache-file引數解決上述錯誤[7][8]:

echo "xorg_cv_malloc0_returns_null=yes" > arm-linux.cache

./configure --prefix=$prefix --host=$host --cache-file=arm-linux.cache

配置好後,就可可以執行以下命令進行編譯

make
在移植過程中,遇到各種各樣的錯誤是難免的,關鍵是找到問題的所在,從而解決它。下面是進行編譯時遇到的第乙個錯誤:

make[3]: entering directory `/home/liyihai/downloads/src/libx11-1.5.0/modules/im/ximcp'

cc imcallbk.lo

in file included from ../../../include/x11/xlibint.h:41:0,

from imcallbk.c:38:

../../../include/x11/xlib.h:44:19: fatal error: x11/x.h: no such file or directory

compilation terminated.

make[3]: *** [imcallbk.lo] error 1

./configure --prefix=$prefix --host=$host

make

make install

這時,上面建立的libx11_install目錄中就多了一些目錄(inclue、lib、share)和其它相關檔案,其中include/x11目錄包含了x.h檔案。

然而,就算有了x.h標頭檔案,在編譯過程中編譯工具也不會自動找到它。其實,使用find命令可以找到ubuntu的/usr/include/x11中是存在x.h這標頭檔案的。現在是交叉編譯,交叉編譯工具不會自動的到/usr/include目錄中去尋找標頭檔案,當然也不會到libx11_install/include這個使用者自己建立的目錄去找,除非使用者指定。

然而,由於makefile的內容太多,而且非常複雜,直接修改其中的includedir變數時,發現無濟於事。這時,唯一的辦法就是指定pkg_config_path環境變數(原因請看《pkg-config》)。

將2.1中的環境變數新增「export pkg_config_path=$prefix/lib/pkgconfig」:

export prefix=/home/liyihai/downloads/libx11_install

export host=arm-arago-linux-gnueabi

export pkg_config_path=$prefix/lib/pkgconfig # 新增

然後再次source env.sh使其生效,然後按照2.2小節的方法重新配置libx11,然後再次編譯即可。

然後,繼續編譯libx11即可解決此問題。

然後,繼續編譯libx11即可解決此問題。

然後,繼續編譯libx11即可解決此問題。

(1)configure: error: xcb requires xsltproc.

那是因為ubuntu中沒有xsltproc這個工具導致的可以使用下面命令安裝乙個:

sudo apt-get install xsltproc
(2)no package 'xcb-proto' found

ubuntu pc需要安裝:

sudo apt-get install xcb-proto
此外,需要交叉編譯:

(3)x11/xauth.h: no such file or directory

(4)cannot find -lxau

由於已經完成了libxau的安裝,因此libxau.so庫已經存在libx11_install/lib目錄中。這時編譯器卻找不到它。因此需要指定庫的路徑。在env.sh中新增ld_library_path設定,如下所示:

export prefix=/home/liyihai/downloads/libx11_install

export host=arm-arago-linux-gnueabi

export ld_library_path=$prefix/lib

export pkg_config_path=$prefix/lib/pkgconfig

執行source env.sh命令使其生效。

繼續編譯libxcb,這時沒有新的錯誤。編譯成功後make install安裝即可。

wget
安裝libx11是最省事的,直接執行以下命令即可。

make install
[1]x window system version 11 release 7.7

[2]編譯tinyx(安裝移植x window)

[3]tinyx的交叉編譯 

[4]arm上tinyx的編譯

[5]tinyx+gtk+2.0forarm

[6]交叉編譯libxcb與x11

[7]configure:checking whether malloc(0) returns null

[8]編譯libx11-1.6.10出現checking whether malloc(0) returns null... configure: error錯誤解決方法

libX11交叉編譯

原始碼鏈結 解壓配置編譯 依賴 xproto xtrans kbproto inputproto libxcb xorgproto 這裡x11的鏈結庫和標頭檔案不能用cflags和ldflags,可能是configure的bug吧 echo enable malloc0returnsnull yes...

11 交叉編譯tiff

11 交叉編譯tiff 目標平台 loongson 1b 開發板 核心 linux 3.0 編譯平台 ubuntu10.04 交叉工具鏈 gcc 3.4.6 2f 一 簡介 tiff是最複雜的一種位 件格式。tiff 是基於標記的檔案格式,它廣泛地應用於對影象質量要求較高的影象的儲存與轉換。由於它的...

編譯 交叉編譯

交叉編譯含義 是指在乙個平台上生成另乙個平台上的可執行 同乙個體系結構可以執行不同的作業系統,同樣乙個作業系統也可以在不同的體系結構上執行 例 常說的x86 linux平台 指inter x86體系結構及linux for x86作業系統 x86 winnt平台 指inter x86體系結構及win...