在華爲海思HI3518上移植和運行QT4.8.6 undefined reference to accept4

http://lbc2100.blog.163.com/blog/static/1505536020149104565701/

 

在HI3531上移植和運行QT4.8.6  

       
 

在HI3531上移植和運行QT4.8.6

1、            前言:

近段有點時間,想把QT移植到HI3531上,在網上查找了很多資料,但都不是很全面,有些有問題也沒有得到很好的體現。

 

2、            環境:

PC:ubuntu10.04

HI3531交叉工具鏈:arm-hisiv100nptl-linux-

QT版本:qt4.8.6(Qt libraries 4.8.6 for embedded Linux (230 MB) 

QT-Creator版本:qt-creator-linux-x86-opensource-2.4.1.bin

 

3、            交叉編譯:

1)      進入qt-everywhere-opensource-src-4.8.6/mkspecs/qws目錄,新建linux-hisi3531nptl-g++目錄,複製linux-arm-g++目錄下的所有文件到linux-hisi3531nptl-g++

cp –a linux-arm-g++/* linux-hisi3531nptl-g++

       2)進入linux-hisi3531nptl-g++,修改文件qmake.conf

             

# modifications to g++.conf

QMAKE_CC               = arm-hisiv100nptl-linux-gcc

QMAKE_CXX             = arm-hisiv100nptl-linux-g++

QMAKE_LINK            = arm-hisiv100nptl-linux-g++

QMAKE_LINK_SHLIB      = arm-hisiv100nptl-linux-g++

 

# modifications to linux.conf

QMAKE_AR                = arm-hisiv100nptl-linux-ar cqs

QMAKE_OBJCOPY          = arm-hisiv100nptl-linux-objcopy

QMAKE_STRIP             = arm-hisiv100nptl-linux-strip

      

3)打開文件qplatformdefs.h增加

#undef O_CLOEXEC

              此處主要爲解決:編譯過程中找不到accept4函數問題(undefined reference to ‘accept4’)

      

4)安裝X11庫

sudo apt-get install libX11-dev libXext-dev libXtst-dev

 

5)返回源碼目錄qt-everywhere-opensource-src-4.8.6進行配置

./configure --prefix=/opt/qt4.8.6 -opensource -confirm-license -qt-sql-sqlite -qt-gfx-linuxfb -plugin-sql-sqlit -no-qt3support -no-phonon -no-svg -no-webkit -no-javascript-jit -no-script -no-scripttools -no-declarative -no-declarative-debug  -qt-zlib -no-gif -qt-libtiff -qt-libpng -no-libmng -qt-libjpeg -no-rpath -no-pch -no-3dnow   -no-avx  -no-neon -no-openssl -no-nis -no-cups -no-dbus -embedded arm -platform linux-g++ -xplatform qws/linux-hisi3531nptl-g++ -little-endian -qt-freetype -no-opengl -no-glib -nomake demos -nomake examples -nomake docs -nomake tools

不需要gui的程序配置:

[plain] view plain copy
 在CODE上查看代碼片派生到我的代碼片
  1. ./configure --prefix=/usr/local/Trolltech/QtEmbedded-4.7.4-linux-hisi3531nptl-g++ -xplatform qws/linux-hisi3531nptl-g++ -opensource -confirm-license -qt-zlib -no-qt3support -make libs -nomake examples -nomake demos -no-multimedia -no-phonon -no-phonon-backend -no-accessibility -no-script -no-scripttools -no-gui -embedded arm  


 

 

其中:  --prefix=/opt/qte4.8.6 爲交叉編譯目標安裝目錄

-xplatform qws/linux-hisi3531nptl-g++指定編譯器及平臺配置信息

5)make

6)make install

 

4、            PC編譯:

1)      重新解壓qt-everywhere-opensource-src-4.8.6.tar.gz,進行PC編譯

2)      ./ configure

3)      make

4)      make install

 

5、            安裝QT開發環境

1)sudo ./qt-creator-opensource-linux-x86-2.4.1.run

2)  下一步直到安裝完成

3)  在應用程序,就可以看到QT Creator

 

6、            配置開發環境

1)從PC的QT安裝目錄中拷貝如下文件到交叉編譯目錄

cp /usr/local/Trolltech/Qt-4.8.6/bin/qml* /opt/qt4.8.6/bin/

 

2)打開QT Creator

3)打開 工具-選項-QT版本

4)打開添加按鍵,添加交叉編譯的qmake

5)進入工具鏈,打開添加按鍵, 選擇GCCE,在編譯器路經選擇arm-hisiv100nptl-linux-g++的路經

 

到些就可以編譯QT下自帶的例子chip了,但這時在HI3531上還是不能顯示的。

 

7、            配置海思HI3531

1) 按照《HIFB開發指南.pdf》 說明加載hifb.ko驅動,這裏需要說明的是,如果QT程序運行在fb0上,分辨率爲1920*1080,顏色格式爲ARGB8888,1buffer模式下,則需要vram0_size = 1920*1080*4=8100K

如果爲2 buffer模式下則需要vram0_size=1920*1080*4*2=16200K

 

說明:爲什麼要使用ARGB8888而不用ARGB1555,是因爲我們QT編譯使用的是32位framebuffer。不然的話會做不了透明處理。

 

2)使能fb0,前提是VO設備已初始化完畢

       static struct fb_bitfield g_r32 = {16,8, 0};

static struct fb_bitfield g_g32 = {8, 8, 0};

static struct fb_bitfield g_b32 = {0, 8, 0};

static struct fb_bitfield g_a32 = {24, 8, 0};

       HI_BOOL show;

       HIFB_ALPHA_S stAlpha;

       struct fb_var_screeninfo stVarInfo;

       fd = open("/dev/fb0", O_RDWR, 0);

      

       show = 0x0;

       ioctl(fd, FBIOPUT_SHOW_HIFB, &show);

 

       stAlpha.bAlphaEnable = 0x1;

       stAlpha.bAlphaChannel = 0x0;

       stAlpha.u8Alpha0 = 0x0;

       stAlpha.u8Alpha1 = 0xff;

       stAlpha.u8GlobalAlpha = 0xff;

       ioctl(fd, FBIOPUT_ALPHA_HIFB, &stAlpha);

 

ioctl(fd, FBIOGET_VSCREENINFO, &stVarInfo);

       stVarInfo.xres = 1920;

       stVarInfo.yres = 1080;

       stVarInfo.xres_virtual = 1920;

       stVarInfo.yres_virtual = 1080;

 

       stVarInfo.transp= g_a32;

       stVarInfo.red = g_r32;

       stVarInfo.green = g_g32;

       stVarInfo.blue = g_b32;

stVarInfo.bits_per_pixel = 32;

    stVarInfo.activate = FB_ACTIVATE_NOW;

ioctl(fd, FBIOPUT_VSCREENINFO, &stVarInfo);

 

show = 0x1;

ioctl(fd, FBIOPUT_SHOW_HIFB, &show);

 

while(1)

{

       Sleep(100);

}

 

              3)配置設備linux環境變量

                     export QT_QWS_FONTDIR=/usr/lib/fonts              //字庫的目錄

                     export QT_QWS_DISPLAY=“linuxFB:/dev/fb0“   //QT顯示在fb0層

 

8、            運行CHIP

OK

9、            實現背景透明

只需要調用QWSServer::setBackground(QColor(0,0,0,0));即可關於這個QColor,在設置的時候,是按照ARGB8888來設置的,前三個數值是RGB,最後一個數值是透明度,0x00是全透,0x7f是半透,0xff是不透。

 

10、如何顯示中文

從c:\windows\fonts 目錄下複製*.ttf文件到字庫目錄,就可以顯示了,但字體需要設置大些。

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