tslib.1.19 移植安裝的問題和步驟

tslib-1.19.tar.gz 可以去官網下載

1.解壓、配置

$ tar zxvf tslib-1.19.tar.gz
$ cd tslib-1.19/
$ CC=arm-hisiv100nptl-linux-gcc ./configure --prefix=`pwd`/res_tslib --host=arm-hisiv100nptl-linux  --enable-static=yes --enable-shared=no

配置的具體信息可以執行 ./configure -h 進行查看,這裏說一下上面的配置:
CC=arm-hisiv100nptl-linux-gcc : 指定 gcc 編譯器,沒指定的話會使用系統默認的編譯器
--prefix=`pwd`/res_tslib : 指定make install時要安裝的目錄
--host=arm-hisiv100nptl-linux : 指定交叉編譯後的程序要運行的 host
--enable-static=yes : 編譯成靜態庫
--enable-shared=no : 禁止編譯動態庫


2.編譯

解壓和配置之後,執行 make 編譯,報錯如下:

$ make
...
make[2]: 正在進入目錄 `/home/samba/tslib/tslib-1.19/tests'
  CCLD     ts_test
../src/.libs/libts.a(ts_setup.o): In function `scan_devices':
ts_setup.c:(.text+0xbc): undefined reference to `EVIOCGPROP'
ts_setup.c:(.text+0x148): undefined reference to `EVIOCGPROP'
ts_setup.c:(.text+0x1c8): undefined reference to `EVIOCGPROP'
ts_setup.c:(.text+0x244): undefined reference to `EVIOCGPROP'
collect2: ld returned 1 exit status
make[2]: *** [ts_test] 錯誤 1
make[2]:正在離開目錄 `/home/samba/tslib/tslib-1.19/tests'
make[1]: *** [all-recursive] 錯誤 1
make[1]:正在離開目錄 `/home/samba/tslib/tslib-1.19'
make: *** [all] 錯誤 2

報錯:EVIOCGPROP 沒有定義。


3.排錯

(1)先試一下是不是配置的問題,直接全部按照默認的配置,編譯一下

$ ./configure --prefix=`pwd`/res_tslib
$ make clean
$ make

結果:make編譯通過,說明是配置的參數問題或編譯器的問題。

(2)只使用默認編譯器,其他配置參數全跟之前一樣

$ ./configure --prefix=`pwd`/res_tslib --enable-static=yes --enable-shared=no
$ make clean
$ make

結果:make編譯通過,說明很大可能是編譯器的問題。

(3)使用其他的交叉編譯器 arm-hisiv400-linux-gcc

$ CC=arm-hisiv400-linux-gcc ./configure --prefix=`pwd`/res_tslib --host=arm-hisiv400-linux  --enable-static=yes --enable-shared=no
$ make clean
$ make

結果:make編譯通過,進一步確定可能是編譯器問題。


(4)定位問題,並修改

①結合報錯原因 “EVIOCGPROP 沒定義”,猜測 EVIOCGPROP 可能是在編譯器的頭文件定義的,所以去安裝編譯器的目前搜索一下

  • 找到 arm-hisiv400-linux-gcc 的目錄,搜索 “EVIOCGPROP”,找到在 input.h有該定義
$ which is arm-hisiv400-linux-gcc
/opt/hisi-linux/x86-arm/arm-hisiv400-linux/target/bin/arm-hisiv400-linux-gcc
$ cd /opt/hisi-linux/x86-arm/arm-hisiv400-linux
$ grep "EVIOCGPROP" -rn ./                 
./target/usr/include/linux/input.h:110:#define EVIOCGPROP(len)          _IOC(_IOC_READ, 'E', 0x09, len)         /* get device properties */
$ 
  • 找到 arm-hisiv100nptl-linux-gcc 的目錄,搜索 “EVIOCGPROP”,找不到相關定義
$ which is arm-hisiv100nptl-linux-gcc
/opt/hisi-linux-nptl/arm-hisiv100-linux/target/bin/arm-hisiv100nptl-linux-gcc
$ cd /opt/hisi-linux-nptl/arm-hisiv100-linux/
$ grep "EVIOCGPROP" -rn ./
$

解決方法

  • 打開 src/tslib.h
$ vi src/tslib.h
  • 加入下面這行定義
#define EVIOCGPROP(len)          _IOC(_IOC_READ, 'E', 0x09, len)         /* get device properties */

在這裏插入圖片描述

  • 重新配置、編譯通過、安裝
$ CC=arm-hisiv100nptl-linux-gcc ./configure --prefix=`pwd`/res_tslib --host=arm-hisiv100nptl-linux  --enable-static=yes --enable-shared=no
$ make clean
$ make
$ make install

完成後,在當前目錄會生成一個res_tslib目錄

$ ls res_tslib/
bin  etc  include  lib  share
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章