博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【TINY4412】QT5移植笔记:(2)QT5.7移植到Linux
阅读量:4086 次
发布时间:2019-05-25

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

【TINY4412】QT5移植笔记:(2)QT5.7移植到Linux

宿主机 : 虚拟机 Ubuntu 16.04 LTS / X64

目标板[底板]: Tiny4412SDK - 1506
目标板[核心板]: Tiny4412 - 1412
LINUX内核: 4.12.0
交叉编译器: arm-none-linux-gnueabi-gcc(gcc version 4.8.3 20140320)
日期: 2017-9-16 09:59:02
作者: SY

简介

QT 是奇趣公司开发的基于 C++ 语言的 GUI 框架,具有良好的跨平台特性。在 Windows 开发调试好的程序,重新编译后在 Linux 上就可以运行。

我们将 QT 源码使用交叉编译器重新编译后,烧录到开发板中,就可以运行 QT 程序了!

移植

我们需要从 下载 5.7 版本的源码:qt-everywhere-opensource-src-5.7.0.tar.xz ,为什么选择 5.7 版本的软件呢?因为 5.7 版本以后,将不再支持 Windows XP ,为了保持兼容性才选择这个版本。

安装库

root@ubuntu:/opt/Qt5.7.0/qt-everywhere-opensource-src-5.7.0# apt-get install g++-multilib libx11-dev libxext-dev libxtst-dev zlib1g-dev lib32ncurses5 lib32z1 libpng-dev autoconf automake libtool lsb-coreroot@ubuntu:/opt/Qt5.7.0/qt-everywhere-opensource-src-5.7.0# apt-get install build-essential libfontconfig1 libfontconfig1-dev libxrender-dev libxrender1 libxkbcommon-dev libxkbcommon-x11-0 libxkbcommon-x11-dev libxkbcommon0 libglib2.0-dev libglib2.0-0 libfreetype6 libfreetype6-devroot@ubuntu:/opt/Qt5.7.0/qt-everywhere-opensource-src-5.7.0# apt-get install libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libgconf2-dev libdbus-1-dev libedbus-dev

虚拟机

解压文件

root@ubuntu:/opt/fs/qt/qt5.7.0# lsqt-everywhere-opensource-src-5.7.0.tar.xzroot@ubuntu:/opt/fs/qt/qt5.7.0# tar xf qt-everywhere-opensource-src-5.7.0.tar.xzroot@ubuntu:/opt/fs/qt/qt5.7.0# lsqt-everywhere-opensource-src-5.7.0root@ubuntu:/opt/fs/qt/qt5.7.0# cd qt-everywhere-opensource-src-5.7.0/root@ubuntu:/opt/fs/qt/qt5.7.0/qt-everywhere-opensource-src-5.7.0# lscoin                LICENSE.LGPLv3              qtconnectivity      qtmultimedia      qtserialport       qtwebviewconfigure           LICENSE.PREVIEW.COMMERCIAL  qtdatavis3d         qt.pro            qtsvg              qtwinextrasconfigure.bat       Makefile                    qtdeclarative       qtpurchasing      qttools            qtx11extrasgnuwin32            qt3d                        qtdoc               qtquickcontrols   qttranslations     qtxmlpatternsLGPL_EXCEPTION.txt  qtactiveqt                  qtgamepad           qtquickcontrols2  qtvirtualkeyboard  READMELICENSE.FDL         qtandroidextras             qtgraphicaleffects  qtscript          qtwaylandLICENSE.GPLv2       qtbase                      qtimageformats      qtscxml           qtwebchannelLICENSE.GPLv3       qtcanvas3d                  qtlocation          qtsensors         qtwebengineLICENSE.LGPLv21     qtcharts                    qtmacextras         qtserialbus       qtwebsocketsroot@ubuntu:/opt/Qt5.7.0/qt-everywhere-opensource-src-5.7.0# mkdir /usr/local/Qt5.7.0

修改配置文件

root@ubuntu:/opt/fs/qt/qt5.7.0/qt-everywhere-opensource-src-5.7.0# vim qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf

修改为以下内容

## qmake configuration for building with arm-linux-gnueabi-g++#MAKEFILE_GENERATOR      = UNIXCONFIG                 += incrementalQMAKE_INCREMENTAL_STYLE = sublibQT_QPA_DEFAULT_PLATFORM = linuxfb QMAKE_CFLAGS  += -msoft-float -D__GCC_FLOAT_NOT_NEEDED -march=armv7-a -mtune=cortex-a9QMAKE_CXXFLAGS += -msoft-float -D__GCC_FLOAT_NOT_NEEDED -march=armv7-a -mtune=cortex-a9include(../common/linux.conf)include(../common/gcc-base-unix.conf)include(../common/g++-unix.conf)# modifications to g++.confQMAKE_CC                = arm-none-linux-gnueabi-gcc -ltsQMAKE_CXX               = arm-none-linux-gnueabi-g++ -ltsQMAKE_LINK              = arm-none-linux-gnueabi-g++ -ltsQMAKE_LINK_SHLIB        = arm-none-linux-gnueabi-g++ -lts# modifications to linux.confQMAKE_AR                = arm-none-linux-gnueabi-ar cqsQMAKE_OBJCOPY           = arm-none-linux-gnueabi-objcopyQMAKE_NM                = arm-none-linux-gnueabi-nm -PQMAKE_STRIP             = arm-none-linux-gnueabi-stripload(qt_config)

建立安装目录

root@ubuntu:/opt/fs/qt/qt5.7.0/qt-everywhere-opensource-src-5.7.0/qtbase/mkspecs/linux-arm-gnueabi-g++# mkdir -p /usr/local/Qt5.7.0

建立一个 configurate 脚本

#!/bin/bash################################################## Developer: SY# Data     : 2017-9-16 10:26:13# Function : Auto Configure Project#################################################./configure  -prefix /usr/local/Qt5.7.0 \  -opensource \  -release \  -confirm-license \  -xplatform linux-arm-gnueabi-g++ \  -shared \  -qt-zlib \  -no-gif \  -qt-libjpeg \  -no-nis \  -no-opengl \  -no-cups \  -no-glib \  -no-dbus \  -no-rpath \  -no-sse2 -no-sse3 -no-ssse3 -no-sse4.1 -no-sse4.2 \  -no-avx  \  -no-openssl \  -nomake tools \  -qreal float \  -qt-libpng \  -tslib \  -skip qtdeclarative \  -nomake examples \  -I /usr/local/tslib/include \  -L /usr/local/tslib/lib \echo "done!"
  • 支持多点触摸:-mtdev -xinput2 ,但是添加会出错。

执行脚本

root@ubuntu:/opt/fs/qt/qt5.7.0/qt-everywhere-opensource-src-5.7.0# ./auto_configurate.sh   ...Build options:  Configuration .......... accessibility audio-backend c++11 clock-gettime clock-monotonic compile_examples concurrent cross_compile doubleconversion evdev eventfd freetype full-config getaddrinfo getifaddrs harfbuzz iconv inotify ipv6ifname large-config largefile linuxfb medium-config minimal-config mremap no-gif no-pkg-config pcre png poll_ppoll posix_fallocate qpa qpa reduce_exports release shared small-config threadsafe-cloexec tslib zlib   Build parts ............ libs  Mode ................... release  Using sanitizer(s)...... none  Using C++ standard ..... c++11  Using gold linker....... no  Using new DTAGS ........ no  Using PCH .............. no  Using LTCG ............. no  Target compiler supports:    Neon ................. noQt modules and options:  Qt D-Bus ............... no  Qt Concurrent .......... yes  Qt GUI ................. yes  Qt Widgets ............. yes  Large File ............. yes  QML debugging .......... yes  Use system proxies ..... noSupport enabled for:  Accessibility .......... yes  ALSA ................... no  CUPS ................... no  DoubleConversion........ yes (bundled copy)  Evdev .................. yes  FontConfig ............. no  FreeType ............... yes (bundled copy)  Glib ................... no  GStreamer .............. no  GTK platformtheme ...... no  HarfBuzz ............... yes (bundled copy)  Iconv .................. yes  ICU .................... no  Image formats:     GIF .................. no    JPEG ................. yes (plugin, using bundled copy)    PNG .................. yes (in QtGui, using bundled copy)  libinput................ no  Logging backends:     journald ............... no    syslog   ............... no  mtdev .................. no  Networking:     getaddrinfo .......... yes    getifaddrs ........... yes    IPv6 ifname .......... yes    libproxy.............. no    OpenSSL .............. no  NIS .................... no  OpenGL / OpenVG:     EGL .................. no    OpenGL ............... no    OpenVG ............... no  PCRE ................... yes (bundled copy)  pkg-config ............. no   PulseAudio ............. no  QPA backends:     DirectFB ............. no    EGLFS ................ no      EGLFS i.MX6 ........ no      EGLFS i.MX6 Wayland. no      EGLFS EGLDevice .... no      EGLFS GBM .......... no      EGLFS Mali ......... no      EGLFS Raspberry Pi . no      EGLFS X11 .......... no    LinuxFB .............. yes    Mir client............ no    XCB .................. no  Session management ..... yes  SQL drivers:     DB2 .................. no    InterBase ............ no    MySQL ................ no    OCI .................. no    ODBC ................. no    PostgreSQL ........... no    SQLite 2 ............. no    SQLite ............... yes (plugin, using bundled copy)    TDS .................. no  tslib .................. yes  udev ................... no  xkbcommon-x11........... no  xkbcommon-evdev......... no  zlib ................... yes (bundled copy)Qt is now configured for building. Just run 'make'.Once everything is built, you must run 'make install'.Qt will be installed into /usr/local/Qt5.7.0Prior to reconfiguration, make sure you remove any leftovers fromthe previous build.done!

注意,在脚本中有一个很重要配置:-skip qtdeclarative \ ,如果不加上这一句,在编译时出现错误:

Project MESSAGE: Hunspell not found! Spell correction will not be available.Project ERROR: Unknown module(s) in QT: quickMakefile:44: recipe for target 'sub-virtualkeyboard-make_first' failedmake[2]: *** [sub-virtualkeyboard-make_first] Error 3

参考网上帖子:

安装各种库,参考:qtbase/src/plugins/platforms/xcb/README

root@ubuntu:/opt/fs/qt/qt5.7.0/qt-everywhere-opensource-src-5.7.0/ apt-get install libncurses5-dev libreadline-dev libxcb1 libxcb1-dev libx11-xcb1 libx11-xcb-dev libxcb-keysyms1 libxcb-keysyms1-dev libxcb-image0 libxcb-image0-dev libxcb-shm0 libxcb-shm0-dev libxcb-icccm4 libxcb-icccm4-dev libxcb-sync-dev libxcb-xfixes0-dev libxrender-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-render-util0 libxcb-render-util0-dev libxcb-glx0-dev libxcb-xinerama0-dev

然后执行:make -j4

然后执行:make install ,安装文件被安装到路径:/usr/local/Qt5.7.0

root@ubuntu:/home/sy# cd /usr/local/Qt5.7.0/root@ubuntu:/usr/local/Qt5.7.0# lsbin  doc  include  lib  mkspecs  plugins  translationsroot@ubuntu:/usr/local/Qt5.7.0# cd bin/root@ubuntu:/usr/local/Qt5.7.0/bin# lscanbusutil        lconvert  lupdate  qdoc   qmake   qtpaths       rcc        uic          xmlpatternsvalidatorfixqt4headers.pl  lrelease  moc      qlalr  qtdiag  qtplugininfo  syncqt.pl  xmlpatterns

其中:qmake 就是用于自动生成 Makefile 的工具,以后编译 qt 工程的时候会经常遇到。

编译应用程序

生成 Makefile

root@ubuntu:/opt/fs/rootfs/rootfs/tmp/GDB# /usr/local/Qt5.7.0/bin/qmake GDB.proInfo: creating stash file /opt/fs/rootfs/rootfs/tmp/GDB/.qmake.stashroot@ubuntu:/opt/fs/rootfs/rootfs/tmp/GDB# lsapp.ico    crc16.h       GDB.pro.user.4b6dd04  mainwindow.h   RES           UAC.rc     xml.cppconfig     GDB.pro       main.cpp              mainwindow.ui  res.qrc       utils.cpp  xml.hcrc16.cpp  GDB.pro.user  mainwindow.cpp        Makefile       UAC.manifest  utils.h

然后 make

root@ubuntu:/opt/fs/rootfs/rootfs/tmp/GDB# makeroot@ubuntu:/opt/fs/rootfs/rootfs/tmp/GDB# lsapp.ico    GDB                   main.o          Makefile            moc_xml.cpp  res.qrc          utils.hconfig     GDB.pro               mainwindow.cpp  moc_crc16.cpp       moc_xml.o    UAC.manifest     utils.ocrc16.cpp  GDB.pro.user          mainwindow.h    moc_crc16.o         qrc_res.cpp  UAC.rc           xml.cppcrc16.h    GDB.pro.user.4b6dd04  mainwindow.o    moc_mainwindow.cpp  qrc_res.o    ui_mainwindow.h  xml.hcrc16.o    main.cpp              mainwindow.ui   moc_mainwindow.o    RES          utils.cpp        xml.o

生成 GDB 可执行程序,将文件拷贝到开发板就可以运行。

用上述方法可以运行 QT 官方的例程:

root@ubuntu:/# cd /opt/fs/qt/qt5.7.0/qt-everywhere-opensource-src-5.7.0/qtbase/examples/root@ubuntu:/opt/fs/qt/qt5.7.0/qt-everywhere-opensource-src-5.7.0/qtbase/examples# lsaggregate  dbus      examples.pro  Makefile  opengl  qpa           qtestlib  sql    widgetscorelib    embedded  gui           network   qmake   qtconcurrent  README    touch  xmlroot@ubuntu:/opt/fs/qt/qt5.7.0/qt-everywhere-opensource-src-5.7.0/qtbase/examples# /usr/local/Qt5.7.0/bin/qmake root@ubuntu:/opt/fs/qt/qt5.7.0/qt-everywhere-opensource-src-5.7.0/qtbase/examples# makeroot@ubuntu:/opt/fs/qt/qt5.7.0/qt-everywhere-opensource-src-5.7.0/qtbase/examples# make clean

这样所有的例程全部编译完毕,烧录到 linux 中执行。

看到演示效果才发现以 linuxfb 运行的程序,全部都没有边框。没有右上角的 X - 标识。

开发板

将该目录下的所有文件拷贝到开发板的根文件系统:

root@ubuntu:/usr/local/Qt5.7.0# cp -a * /opt/fs/rootfs/rootfs/usr/local/Qt5.7.0/

修改配置文件

root@ubuntu:/opt/fs/rootfs/rootfs# cat etc/profile# /etc/profile: system-wide .profile file for the Bourne shellsecho ""echo -n "Processing /etc/profile... "# No core files by defaultulimit -S -c 0 > /dev/null 2>&1USER="`id -un`"LOGNAME=$USERHOSTNAME='/bin/hostname'PS1='[\u@\h:\w]# 'PATH=$PATHexport USER LOGNAME PS1 PATH# tslibexport T_ROOT=/usr/local/tslibexport LD_LIBRARY_PATH=/usr/local/tslib/lib:$LD_LIBRARY_PATHexport TSLIB_CONSOLEDEVICE=noneexport TSLIB_FBDEVICE=/dev/fb0export TSLIB_TSDEVICE=/dev/input/event0export TSLIB_PLUGINDIR=$T_ROOT/lib/tsexport TSLIB_CONFFILE=$T_ROOT/etc/ts.confexport POINTERCAL_FILE=/etc/pointercalexport TSLIB_CALIBFILE=/etc/pointercal# Qtexport QTEDIR=/usr/local/Qt5.7.0export LD_LIBRARY_PATH=/usr/local/Qt5.7.0/lib:$LD_LIBRARY_PATHexport QT_QPA_GENERIC_PLUGINS=tslibexport QT_QPA_FONTDIR=$QTEDIR/lib/fontsexport QT_QPA_PLATFORM_PLUGIN_PATH=$QTEDIR/pluginsexport QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0:size=800x480:mmSize=800x480:offset=0x0:tty=/dev/tty1export QT_QPA_FB_TSLIB=1export QT_QPA_FB_HIDECURSOR=/dev/input/mouse1export LD_PRELOAD=$QTEDIR/lib/preloadable_libiconv.soecho "Done!"

添加字体

从友善之臂的光盘中拷贝字体:DroidSansFallback.ttf 放到开发板路径:/usr/local/Qt5.7.0/lib/fonts

添加字体路径:

[root@TINY4412:~]# vi etc/profileexport QTEDIR=/usr/local/Qt5.7.0export QT_QPA_FONTDIR=$QTEDIR/lib/fonts

添加键盘

参考

将键盘插入开发板

[root@TINY4412:~]# [  356.181581] usb 2-2.3: new low-speed USB device number 5 using exynos-ehci[  356.338068] usb 2-2.3: New USB device found, idVendor=1c4f, idProduct=0002[  356.338218] usb 2-2.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0[  356.338358] usb 2-2.3: Product: USB Keyboard[  356.338454] usb 2-2.3: Manufacturer: SIGMACHIP[  356.349473] input: SIGMACHIP USB Keyboard as /devices/platform/12580000.ehci/usb2/2-2/2-2.3/2-2.3:1.0/0003:1C4F:0002.0001/input/input4[  356.415871] hid-generic 0003:1C4F:0002.0001: input: USB HID v1.10 Keyboard [SIGMACHIP USB Keyboard] on usb-12580000.ehci-2.3/input0[  356.454307] input: SIGMACHIP USB Keyboard as /devices/platform/12580000.ehci/usb2/2-2/2-2.3/2-2.3:1.1/0003:1C4F:0002.0002/input/input5[  356.522293] hid-generic 0003:1C4F:0002.0002: input: USB HID v1.10 Device [SIGMACHIP USB Keyboard] on usb-12580000.ehci-2.3/input1

查看 proc

[root@TINY4412:~]# cat /proc/bus/input/devices I: Bus=0003 Vendor=1c4f Product=0002 Version=0110N: Name="SIGMACHIP USB Keyboard"P: Phys=usb-12580000.ehci-2.3/input0S: Sysfs=/devices/platform/12580000.ehci/usb2/2-2/2-2.3/2-2.3:1.0/0003:1C4F:0002.0001/input/input4U: Uniq=H: Handlers=sysrq kbd leds event4 B: PROP=0B: EV=120013B: KEY=10000 7 ff800000 7ff febeffdf f3cfffff ffffffff fffffffeB: MSC=10B: LED=7I: Bus=0003 Vendor=1c4f Product=0002 Version=0110N: Name="SIGMACHIP USB Keyboard"P: Phys=usb-12580000.ehci-2.3/input1S: Sysfs=/devices/platform/12580000.ehci/usb2/2-2/2-2.3/2-2.3:1.1/0003:1C4F:0002.0002/input/input5U: Uniq=H: Handlers=kbd event5 B: PROP=0B: EV=1fB: KEY=3007f 0 0 0 0 483ffff 17aff32d bf544446 0 0 1 130c13 b17c000 267bfa d941dfed 9e1680 4400 0 10000002B: REL=40B: ABS=1 0B: MSC=10

鼠标含有 2 个接口,因此识别为 dev/input/event4 dev/input/event5

按照 qt 的说明文档,需要添加 QWS_KEYBOARD 环境变量

export QWS_KEYBOARD=/dev/input/event4

但是实测插上键盘后直接可以输入数据,不添加环境变量也可以。

添加鼠标

将鼠标插入开发板

[root@TINY4412:~]# [ 1016.121660] usb 2-2.3: new low-speed USB device number 13 using exynos-ehci[ 1016.276005] usb 2-2.3: New USB device found, idVendor=275d, idProduct=0ba6[ 1016.276198] usb 2-2.3: New USB device strings: Mfr=0, Product=1, SerialNumber=0[ 1016.276364] usb 2-2.3: Product: USB OPTICAL MOUSE [ 1016.288896] input: USB OPTICAL MOUSE  as /devices/platform/12580000.ehci/usb2/2-2/2-2.3/2-2.3:1.0/0003:275D:0BA6.000F/input/input18[ 1016.292002] hid-generic 0003:275D:0BA6.000F: input: USB HID v1.11 Mouse [USB OPTICAL MOUSE ] on usb-12580000.ehci-2.3/input0

查看 proc

[root@TINY4412:~]# cat /proc/bus/input/devices I: Bus=0003 Vendor=275d Product=0ba6 Version=0111N: Name="USB OPTICAL MOUSE "P: Phys=usb-12580000.ehci-2.3/input0S: Sysfs=/devices/platform/12580000.ehci/usb2/2-2/2-2.3/2-2.3:1.0/0003:275D:0BA6.000F/input/input18U: Uniq=H: Handlers=mouse1 event6 B: PROP=0B: EV=17B: KEY=70000 0 0 0 0 0 0 0 0B: REL=103B: MSC=10

鼠标被识别为 dev/input/mouse1

[root@TINY4412:~]# vi /etc/profileexport QT_QPA_FB_HIDECURSOR=/dev/input/mouse1

添加触摸屏

[root@TINY4412:~]# vi etc/profile export QT_QPA_FB_TSLIB=1

添加虚拟键盘

下载 源码,

root@ubuntu:/opt/fs/qt/qt5.7.0# lsqt-everywhere-opensource-src-5.7.0  qtvirtualkeyboard-opensource-src-5.7.0.tar.xzroot@ubuntu:/opt/fs/qt/qt5.7.0# tar xf qtvirtualkeyboard-opensource-src-5.7.0.tar.xz root@ubuntu:/opt/fs/qt/qt5.7.0# lsqt-everywhere-opensource-src-5.7.0      qtvirtualkeyboard-opensource-src-5.7.0.tar.xzqtvirtualkeyboard-opensource-src-5.7.0root@ubuntu:/opt/fs/qt/qt5.7.0# rm -rf qtvirtualkeyboard-opensource-src-5.7.0.tar.xz root@ubuntu:/opt/fs/qt/qt5.7.0# lsqt-everywhere-opensource-src-5.7.0  qtvirtualkeyboard-opensource-src-5.7.0root@ubuntu:/opt/fs/qt/qt5.7.0# cd qtvirtualkeyboard-opensource-src-5.7.0/root@ubuntu:/opt/fs/qt/qt5.7.0/qtvirtualkeyboard-opensource-src-5.7.0# lsdist  examples  LICENSE.GPL3  Makefile  mkspecs  qtvirtualkeyboard.pro  README.md  src  sync.profile  tests

配置支持拼音输入法

root@ubuntu:/opt/fs/qt/qt5.7.0/qtvirtualkeyboard-opensource-src-5.7.0# /usr/local/Qt5.7.0/bin/qmake CONFIG+="lang-en_GB lang-zh_CN"

编译

root@ubuntu:/opt/fs/qt/qt5.7.0/qtvirtualkeyboard-opensource-src-5.7.0# makecd src/ && ( test -e Makefile || /usr/local/Qt5.7.0/bin/qmake /opt/fs/qt/qt5.7.0/qtvirtualkeyboard-opensource-src-5.7.0/src/src.pro -o Makefile ) && make -f Makefile make[1]: Entering directory '/opt/fs/qt/qt5.7.0/qtvirtualkeyboard-opensource-src-5.7.0/src'cd virtualkeyboard/ && ( test -e Makefile || /usr/local/Qt5.7.0/bin/qmake /opt/fs/qt/qt5.7.0/qtvirtualkeyboard-opensource-src-5.7.0/src/virtualkeyboard/virtualkeyboard.pro '+=lang-en_GB lang-zh_CN' -o Makefile ) && make -f Makefile (command line): Assignment needs exactly one word on the left hand side.Project MESSAGE: Hunspell not found! Spell correction will not be available.Project ERROR: Unknown module(s) in QT: qml quickMakefile:44: recipe for target 'sub-virtualkeyboard-make_first' failedmake[1]: *** [sub-virtualkeyboard-make_first] Error 3make[1]: Leaving directory '/opt/fs/qt/qt5.7.0/qtvirtualkeyboard-opensource-src-5.7.0/src'Makefile:44: recipe for target 'sub-src-make_first' failedmake: *** [sub-src-make_first] Error 2

这个问题在编译 qt 时就出现,一直没找到解决方案,留着以后解决。

测试

运行官方例程:

[root@TINY4412:/opt/examples]# ./touch/pinchzoom/pinchzoomQIconvCodec::convertToUnicode: using Latin-1 for conversion, iconv_open failedQIconvCodec::convertFromUnicode: using Latin-1 for conversion, iconv_open failed

这里写图片描述

参考: ,下载:libiconv-1.14.tar.gz

出现错误:iconv_open failed

c

root@ubuntu:/opt/fs/qt/qt5.7.0# ls
libiconv-1.14.tar.gz qt-everywhere-opensource-src-5.7.0 qtvirtualkeyboard-opensource-src-5.7.0
root@ubuntu:/opt/fs/qt/qt5.7.0# tar zxf libiconv-1.14.tar.gz
root@ubuntu:/opt/fs/qt/qt5.7.0# ls
libiconv-1.14 libiconv-1.14.tar.gz qt-everywhere-opensource-src-5.7.0 qtvirtualkeyboard-opensource-src-5.7.0
root@ubuntu:/opt/fs/qt/qt5.7.0# rm -rf libiconv-1.14.tar.gz
root@ubuntu:/opt/fs/qt/qt5.7.0# ls
libiconv-1.14 qt-everywhere-opensource-src-5.7.0 qtvirtualkeyboard-opensource-src-5.7.0
root@ubuntu:/opt/fs/qt/qt5.7.0# cd libiconv-1.14/
root@ubuntu:/opt/fs/qt/qt5.7.0/libiconv-1.14# ls
ABOUT-NLS ChangeLog COPYING.LIB extras lib man PORTS src tools
aclocal.m4 config.h.in DEPENDENCIES gnulib-local libcharset NEWS preload srclib windows
AUTHORS configure DESIGN HACKING m4 NOTES README srcm4 woe32dll
autogen.sh configure.ac djgpp include Makefile.devel os2 README.djgpp tests
build-aux COPYING doc INSTALL.generic Makefile.in po README.woe32 THANKS
root@ubuntu:/opt/fs/qt/qt5.7.0/libiconv-1.14# ./configure -prefix=$PWD/_install -host=arm-none-linux-gnueabi
...
root@ubuntu:/opt/fs/qt/qt5.7.0/libiconv-1.14# make

出现错误:

In file included from progname.c:26:0:./stdio.h:1010:1: error: 'gets' undeclared here (not in a function) _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); ^Makefile:914: recipe for target 'progname.o' failedmake[2]: *** [progname.o] Error 1make[2]: Leaving directory '/opt/fs/qt/qt5.7.0/libiconv-1.14/srclib'Makefile:865: recipe for target 'all' failedmake[1]: *** [all] Error 2make[1]: Leaving directory '/opt/fs/qt/qt5.7.0/libiconv-1.14/srclib'Makefile:33: recipe for target 'all' failedmake: *** [all] Error 2

做如下修改:

root@ubuntu:/opt/fs/qt/qt5.7.0/libiconv-1.14# vim srclib/stdio.in.h 694 _GL_CXXALIASWARN (gets); 695 /* It is very rare that the developer ever has full control of stdin, 696    so any use of gets warrants an unconditional warning.  Assume it is 697    always declared, since it is required by C89.  */ 698 /* _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); */ 699 #if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16) 700     _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); 701 #endif

编译成功!

root@ubuntu:/opt/fs/qt/qt5.7.0/libiconv-1.14# make installroot@ubuntu:/opt/fs/qt/qt5.7.0/libiconv-1.14# cd _install/root@ubuntu:/opt/fs/qt/qt5.7.0/libiconv-1.14/_install# lsbin  include  lib  share

拷贝库到开发板

root@ubuntu:/opt/fs/qt/qt5.7.0/libiconv-1.14/_install# cp lib/preloadable_libiconv.so /opt/fs/rootfs/rootfs/usr/local/Qt5.7.0/lib/

添加到环境变量

[root@TINY4412:~]# vi /etc/profile export QTEDIR=/usr/local/Qt5.7.0export LD_PRELOAD=$QTEDIR/lib/preloadable_libiconv.so[root@TINY4412:~]# source /etc/profile

再次运行程序,错误消失!

参考

你可能感兴趣的文章
CentOS7,玩转samba服务,基于身份验证的共享
查看>>
计算机网络-网络协议模型
查看>>
计算机网络-OSI各层概述
查看>>
Java--String/StringBuffer/StringBuilder区别
查看>>
mySQL--深入理解事务隔离级别
查看>>
分布式之redis复习精讲
查看>>
数据结构与算法7-栈
查看>>
线性数据结构学习笔记
查看>>
数据结构与算法9-递归
查看>>
数据结构与算法10-冒泡排序、插入排序、选择排序
查看>>
数据结构与算法14-跳表
查看>>
Java并发编程 | 一不小心就死锁了,怎么办?
查看>>
计算机组成原理 | 冯·诺依曼体系结构:计算机组成的金字塔 | 极客时间
查看>>
JAVA语言核心精讲1-Java语言特性
查看>>
JAVA语言核心精讲2-异常相关
查看>>
JAVA语言核心精讲5-反射机制与动态代理原理
查看>>
JAVA语言核心精讲7--ArrayList/Vector/LinkedList对比
查看>>
Lombok老母猪
查看>>
Mybatis中javaType和jdbcType对应关系
查看>>
lombok的@EqualsAndHashCode注解
查看>>