zoukankan      html  css  js  c++  java
  • OK6410 & QT (2):交叉编译QT LIB

    HOST:ubuntu 12.04LTS, 64bit, Core i7-4790K,gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)

    CROSS-TOOLCHAIN:gcc version 4.4.1 (Sourcery G++ Lite 2009q3-67)

    SRC:

    tslib-1.4.tar.gz 

    qt-everywhere-opensource-src-5.6.1.tar.gz 

    qt-opensource-linux-x64-5.6.1.run

    1 编译linux_atomic库,(undefined reference to `__sync_sub_and_fetch_4' ),高版本的交叉编译工具可以无视;

    参考[http://blog.csdn.net/wangmingape/article/details/24545775]。

    首先下载gcc 4.6.0源码,在gcc-4.6.0/gcc/config/arm目录下可以找到linux-atomic.c文件。

    将这个文件复制到你的工作目录,最好新建一个文件夹,并添加build.bash脚本

    libtool --tag=CC --mode=compile arm-linux-gcc -g -O2 -MT linux-atomic.lo -MD -MP -MF linux-atomic.Tpo -c -o linux-atomic.lo linux-atomic.c 
    libtool --tag=CC --mode=link arm-linux-g++ -g -O2 -o liblinux-atomic.la linux-atomic.lo
    

      执行后就在你的当前目录在生成.libs文件夹,(tree -a )

    ├── build.bash
    ├── liblinux-atomic.la
    ├── .libs
    │   ├── liblinux-atomic.a
    │   ├── liblinux-atomic.la -> ../liblinux-atomic.la
    │   └── linux-atomic.o
    ├── linux-atomic.c
    ├── linux-atomic.lo
    ├── linux-atomic.o
    └── linux-atomic.Tpo
    

      这个文件夹中文件复制到你的库目录,最好新建文件夹,如 /opt/linux-atomic

    liblinux-atomic.a  liblinux-atomic.la  linux-atomic.o
    

    2 接下来我们开始编译qt,先将qt-everywhere-opensource-src-5.6.1.tar.gz 解压到你的工作目录。

      1)编辑qmake.conf,文件位置在qt-everywhere-opensource-src-5.6.1qtbasemkspecslinux-arm-gnueabi-g++。

     在这个文件里,主要是配置交叉编译工具,tslib的库也需要在这里配置。我的配置如下,红色的是修改的部分:

    #
    # qmake configuration for building with arm-linux-gnueabi-g++
    #
    
    MAKEFILE_GENERATOR      = UNIX
    CONFIG                 += incremental
    QMAKE_INCREMENTAL_STYLE = sublib
    
    #S3C6410
    QT_QPA_DEFAULT_PLATFORM = linuxfb   
    QMAKE_CFLAGS_RELEASE   +=-O2 -march=armv5te
    QMAKE_CXXFLAGS_RELEASE +=-O2 -march=armv5te
    
    QMAKE_INCDIR += /opt/tslib/include
    QMAKE_LIBDIR += /opt/tslib/lib
    
    include(../common/linux.conf)
    include(../common/gcc-base-unix.conf)
    include(../common/g++-unix.conf)
    
    # modifications to g++.conf
    QMAKE_CC                = arm-linux-gcc -lts
    QMAKE_CXX               = arm-linux-g++ -lts
    QMAKE_LINK              = arm-linux-g++ -lts
    QMAKE_LINK_SHLIB        = arm-linux-g++ -lts 
    
    # modifications to linux.conf
    QMAKE_AR                = arm-linux-ar cqs
    QMAKE_OBJCOPY           = arm-linux-objcopy
    QMAKE_NM                = arm-linux-nm -P
    QMAKE_STRIP             = arm-linux-strip
    load(qt_config)
    

      2)在qt-everywhere-opensource-src-5.6.1目录下创建编译脚本,具体如下:

    ./configure -prefix /opt/qt_arm -opensource -confirm-license -release -shared -static -xplatform linux-arm-gnueabi-g++ -optimized-qmake -pch -qt-sql-sqlite -qt-libjpeg -qt-zlib -qt-libpng -qt-freetype -tslib -no-opengl -no-sse2 -no-openssl -no-nis -no-cups -no-glib -no-dbus -no-xcb -no-eglfs -no-xcursor -no-xfixes -no-xrandr -no-xrender -no-separate-debug-info -no-iconv -make libs -make examples -nomake tools -nomake tests -skip qt3d -skip qtcanvas3d -skip qtdoc -skip qtwayland -I/opt/tslib/include -L/opt/tslib/lib -v -llinux-atomic -L/opt/linux-atomic
    

      红色标记出比较重要的地方:

            -prefix :将来库安装目录

        -xplatform:说明使用的conf文件位置,即)mkspecslinux-arm-gnueabi-g++qmake.conf)

            -I/opt/tslib/include -L/opt/tslib/lib:将tslib库加进来

            -llinux-atomic -L/opt/linux-atomic:将atomic库加进来

         3)执行脚本,为下一步的编译做好准备活动,我的环境信息输出如下:

    Building on:   linux-g++ (unknown, CPU features: none detected)
    Building for:  linux-arm-gnueabi-g++ (arm, CPU features: none detected)
    Platform notes:
    
                - Also available for Linux: linux-clang linux-kcc linux-icc linux-cxx
            
    qmake vars .......... styles += mac fusion windows DEFINES += QT_NO_MTDEV DEFINES += QT_NO_LIBUDEV DEFINES += QT_NO_LIBINPUT EXTRA_INCLUDEPATH +=  "/opt/tslib/include" EXTRA_LIBS +=  -L"/opt/tslib/lib" -l"linux-atomic" -L"/opt/linux-atomic" sql-drivers =  sqlite sql-plugins =  qmake switches ......... 
    
    Build options:
      Configuration .......... accessibility audio-backend c++11 clock-gettime clock-monotonic compile_examples concurrent cross_compile enable_new_dtags evdev eventfd freetype full-config getaddrinfo getifaddrs gif harfbuzz inotify ipv6ifname jpeg large-config largefile linuxfb medium-config minimal-config mremap no-pkg-config pcre png posix_fallocate precompile_header qpa qpa reduce_exports release release_tools rpath small-config static threadsafe-cloexec tslib zlib 
      Build parts ............  libs examples
      Mode ................... release; optimized tools
      Using sanitizer(s)...... none
      Using C++ standard ..... c++11
      Using gold linker....... no
      Using new DTAGS ........ yes
      Using PCH .............. yes
      Using LTCG ............. no
      Target compiler supports:
        Neon ................. no
    
    Qt 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 ..... no
    
    Support enabled for:
      Accessibility .......... yes
      ALSA ................... no
      CUPS ................... no
      Evdev .................. yes
      FontConfig ............. no
      FreeType ............... qt
      Glib ................... no
      GStreamer .............. no
      GTK theme .............. no
      HarfBuzz ............... yes (bundled copy)
      Iconv .................. no
      ICU .................... no
      Image formats: 
        GIF .................. yes (in QtGui, using bundled copy)
        JPEG ................. yes (in QtGui, 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 ............... qt-qt
        TDS .................. no
      tslib .................. yes
      udev ................... no
      xkbcommon-x11........... no
      xkbcommon-evdev......... no
      zlib ................... yes (bundled copy)
    
    
    WARNING: Using static linking will disable the use of dynamically
    loaded plugins. Make sure to import all needed static plugins,
    or compile needed modules into the library.
    
    NOTE: Qt is using double for qreal on this system. This is binary incompatible against Qt 5.1.
    Configure with '-qreal float' to create a build that is binary compatible with 5.1.
    
    NOTE: -optimized-tools is not useful in -release mode.
    
    
    Qt is now configured for building. Just run 'make'.
    Once everything is built, you must run 'make install'.
    Qt will be installed into /opt/qt_arm
    
    Prior to reconfiguration, make sure you remove any leftovers from
    the previous build.
    

      4)编译。qt非常大,需要编译比较长的时间,多核的同学注意使用make -jX命令,X是你CPU的核心数,这样可以加快编译速度。

    make -j8 && sudo make -j8 install
    

      5)配置环境变量。这样/opt/qt_arm目录就有了你需要的库了,将库原封不动的搬到开发板,基本上就大功告成了。

    在开发板上建立环境变量:

    export QTDIR=/opt/qt_arm
    export QT_QPA_FONTDIR=$QTDIR/lib/fonts
    export QT_QPA_PLATFORM_PLUGIN_PATH=$QTDIR/plugins/
    export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
    export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0:size=800x600:mmSize=800x600:offset=0x0:tty=/dev/tty1
    
    export QT_QPA_GENERIC_PLUGINS=tslib:/dev/input/event1
    

          在开发板的/opt/qt_arm/examples路径下有一些示例可以直接拿来测试。

    PS: make clean && make distclean总是失败的,重新编译的也会报错,还没有搞清楚哪里的问题。

  • 相关阅读:
    mongo数据更新(修改器)
    mongo数据排序和分页显示
    mongodb数据操作(CRUD)
    mongodb配置和基本操作
    lua语法基本
    awk常见基本使用
    sed命令常见用法
    Python(面向对象编程4——继承顺序、封装)
    Python(面向对象3 ——实例)
    Python(面向对象编程——2 继承、派生、组合、抽象类)
  • 原文地址:https://www.cnblogs.com/duanyongzhen/p/5747998.html
Copyright © 2011-2022 走看看