Setting-up QtCreator to cross compile for RK3288

From ESS-WIKI
Revision as of 01:56, 9 November 2020 by Zhengguang.yang (Talk | contribs) (Created page with "<p><span class="fck_mw_template"><span class="fck_mw_template">{{DISPLAYTITLE:Setting-up QtCreator to cross compile for RK3288}}</span></span> </p> <table align="right"> <tr>...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

_

Prerequisites

All operations in this guide are based on Ubuntu 18.04 LTS 64bit only.
First please install Ubuntu 18.04 LTS 64bit* with minimum 2GB memory.

Installing required packages

Please login and perform the following commands:

$ sudo apt-get install build-essential
$ sudo apt-get install qtcreator
$ sudo apt-get install qt5-default
$ sudo apt-get install qt5-doc
$ sudo apt-get install qt5-doc-html qtbase5-doc-html
$ sudo apt-get install qtbase5-examples

Installing cross toolchain

Please download <a href="<a href="https://pan.baidu.com/s/1OEzbJsgBSo3n5DdwRY2Rag" alt="https://pan.baidu.com/s/1OEzbJsgBSo3n5DdwRY2Rag" title="https://pan.baidu.com/s/1OEzbJsgBSo3n5DdwRY2Rag">https://pan.baidu.com/s/1OEzbJsgBSo3n5DdwRY2Rag</a>" alt="<a href="https://pan.baidu.com/s/1OEzbJsgBSo3n5DdwRY2Rag" alt="https://pan.baidu.com/s/1OEzbJsgBSo3n5DdwRY2Rag" title="https://pan.baidu.com/s/1OEzbJsgBSo3n5DdwRY2Rag">https://pan.baidu.com/s/1OEzbJsgBSo3n5DdwRY2Rag</a>" title="<a href="https://pan.baidu.com/s/1OEzbJsgBSo3n5DdwRY2Rag" alt="https://pan.baidu.com/s/1OEzbJsgBSo3n5DdwRY2Rag" title="https://pan.baidu.com/s/1OEzbJsgBSo3n5DdwRY2Rag">https://pan.baidu.com/s/1OEzbJsgBSo3n5DdwRY2Rag</a>">cross compiler toolchain</a> (Password: 0kkn)first. Then execute the following command to unzip the cross compiler tool to the /opt directory

$ sudo tar -zxf rk3399_toolchain_Qt_V5.12.2.tar.gz -C /opt
</p>
</dl>

Working within QtCreator

Starting the QtCreator

$ qtcreator
  1. The QtCreator's main window shows up.
    <img src="/wiki/images/6/62/RK3399_Qt_start_init.png" _fck_mw_filename="RK3399 Qt start init.png" _fck_mw_upright="1" _fck_mw_origimgwidth="1306" _fck_mw_origimgheight="737" alt="RK3399 Qt start init.png" title="RK3399 Qt start init.png" style="vertical-align:middle;" />
  2. Check QtCreator's version by using "Help" -> "About Qt Creator".
    <img src="/wiki/images/7/7a/RK3399_QtCreator_version.png" _fck_mw_filename="RK3399 QtCreator version.png" _fck_mw_origimgwidth="527" _fck_mw_origimgheight="269" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />

Configuring the Cross-Compiler Options

  1. Bring up the options dialog using "Tools" -> "Options..."
  2. Select the "Devices" page on the left, and click "Add..."
  3. Select "Generic Linux Device" and click "Start Wizard".
    <img src="/wiki/images/9/95/RK3399_Qt_Remote_device_setting.png" _fck_mw_filename="RK3399 Qt Remote device setting.png" _fck_mw_origimgwidth="1366" _fck_mw_origimgheight="904" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />
  4. Specify proper settings and click "Next>"
    <img src="/wiki/images/4/4f/RK3288_Qt_ssh_device.png" _fck_mw_filename="RK3288 Qt ssh device.png" _fck_mw_origimgwidth="1361" _fck_mw_origimgheight="902" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />
  5. Click "Finish"
  6. Device test finished successfully. Click "Close".
    <img src="/wiki/images/2/28/RK3288_Qt_ssh_connect.png" _fck_mw_filename="RK3288 Qt ssh connect.png" _fck_mw_origimgwidth="607" _fck_mw_origimgheight="610" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />

    If device test failed, please go back to specify proper settings.
    <img src="/wiki/images/b/b4/2015-02-24_113504.png" _fck_mw_filename="2015-02-24 113504.png" _fck_mw_origimgwidth="616" _fck_mw_origimgheight="125" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" /> </dt>
    </dd>

    (It is necessary to set a blank password at least, null password does not work.)

    <img src="/wiki/images/c/c8/2015-02-24_113635.png" _fck_mw_filename="2015-02-24 113635.png" _fck_mw_origimgwidth="616" _fck_mw_origimgheight="123" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />
    (It means device's IP is incorrect or some network issues occured.)
    </dl></li>

  7. Click "Apply"
  8. Select the "Build & Run" page on the left, switch to "Compilers" tab, drop down "Add" menu and choose "GCC-->C++".
  9. Name the compiler as "RK G++"
  10. Click "Browse..." to select "/opt/rk3288_risc/buildroot/output/rockchip_rk3288/host/bin/arm-buildroot-linux-gnueabihf-g++"
  11. Click "Apply"
    <img src="/wiki/images/2/2f/RK3288_Qt_g%2B%2B.png" _fck_mw_filename="RK3288 Qt g++.png" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />
  12. Switch to the "Debuggers" tab
  13. Click "Add"
  14. Name the debugger as "RK GDB"
  15. Click "Browse..." to select "/opt/rk3288_risc/buildroot/output/rockchip_rk3288/host/bin/arm-buildroot-linux-gnueabihf-gdb"
  16. Click "Apply"
    <img src="/wiki/images/b/b4/RK3288_Qt_GDB.png" _fck_mw_filename="RK3288 Qt GDB.png" _fck_mw_origimgwidth="1363" _fck_mw_origimgheight="907" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />
  17. Switch to the "Qt Versions" tab.
  18. Check if the "Qt 5.9.4 (host)" is auto detected in "Manual" item ?
    <img src="/wiki/images/d/d3/RK3288_Qt_version.png" _fck_mw_filename="RK3288 Qt version.png" _fck_mw_origimgwidth="1363" _fck_mw_origimgheight="907" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />
    If not, click "Add..." to choose the proper qmake.
  19. Click "Apply"
  20. Switch to the "Kits" tab.
  21. Click "Add".
  22. Name the kit as "RK toolchain"
  23. Specify the correct "Device Tpye", "Compiler", "Debugger" and "Qt version"
  24. Click "Browse..." to select "/opt/rk3288_risc/buildroot/output/rockchip_rk3288/host/arm-buildroot-linux-gnueabihf/sysroot" as sysroot
  25. Click Apply
    <img src="/wiki/images/a/ab/RK3288_Qt_toolchain.png" _fck_mw_filename="RK3288 Qt toolchain.png" _fck_mw_origimgwidth="1363" _fck_mw_origimgheight="907" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />
  26. Click OK to finalize the configuration.
  27. Invoke the options dialog again to make sure the "iMX6 toolchain" is default kit.
  28. </ol>

    Creating the Project

    1. Bring up "New" dailog using "File" -> "New File or Project..."
    2. Select "Applications" -> 'Qt Widgets Application"
    3. Click "Choose..."
      <img src="/wiki/images/4/4b/RK3399_Project_001.png" _fck_mw_filename="RK3399 Project 001.png" _fck_mw_origimgwidth="1308" _fck_mw_origimgheight="733" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />
    4. Use "hello_qt" as name
    5. Create in "/mnt/sda1/work/qt/PJ"
    6. Click "Next"
      <img src="/wiki/images/9/92/RK3288_Qt_project_name_local.PNG" _fck_mw_filename="RK3288 Qt project name local.PNG" _fck_mw_origimgwidth="731" _fck_mw_origimgheight="130" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />
    7. Check "RK3288 toolchain"
    8. Click "Next".
      <img src="/wiki/images/6/69/RK3288_Qt_project_kit_select.png" _fck_mw_filename="RK3288 Qt project kit select.png" _fck_mw_origimgwidth="1398" _fck_mw_origimgheight="735" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />
    9. Use default settings for "Class Information"
    10. Click "Next"
      <img src="/wiki/images/7/7c/RK3399_QT_Project_last.png" _fck_mw_filename="RK3399 QT Project last.png" _fck_mw_origimgwidth="1304" _fck_mw_origimgheight="731" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />
    11. Use default settings for "Project Management"
    12. Click "Finish"
      <img src="/wiki/images/d/db/RK3288_Qt_project_finish.png" _fck_mw_filename="RK3288 Qt project finish.png" _fck_mw_origimgwidth="1399" _fck_mw_origimgheight="737" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />
    13. Double click "hello_qt.pro" to switch to editor window
    14. In new project it is necessary to add following two lines into qt project file.
      target.path = ./
      INSTALLS += target

      <img src="/wiki/images/5/5b/RK3288_Qt_code_pro.png" _fck_mw_filename="RK3288 Qt code pro.png" _fck_mw_origimgwidth="1400" _fck_mw_origimgheight="740" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />
    15. Press "Ctrl+S" to save file.
    16. Double click "mainwindow.ui" to switch to Design mode
    17. Drag & drop one Label widget on main form, use property editor on the right side to change text and font size
      <img src="/wiki/images/3/31/2015-01-30_174418.png" _fck_mw_filename="2015-01-30 174418.png" _fck_mw_origimgwidth="279" _fck_mw_origimgheight="338" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />
      <img src="/wiki/images/b/b6/RK3288_Qt_code_window_size.png" _fck_mw_filename="RK3288 Qt code window size.png" _fck_mw_origimgwidth="1400" _fck_mw_origimgheight="740" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />
    18. Save all project files using "File" -> "Save All"

    Building the Project

    1. Switch to "Projects" mode
    2. Check if "build configuration" is set to "Debug".
      <img src="/wiki/images/c/c5/RK3288_Qt_debug_setting.png" _fck_mw_filename="RK3288 Qt debug setting.png" _fck_mw_origimgwidth="1400" _fck_mw_origimgheight="740" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />
    3. Check if "Files to deploy" is correct
      <img src="/wiki/images/5/5e/RK3288_Qt_debug_run.png" _fck_mw_filename="RK3288 Qt debug run.png" _fck_mw_origimgwidth="1400" _fck_mw_origimgheight="740" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />
    4. Set environment variable DISPLAY in QtCreator -> Projects -> Run -> Run Environment. The value of DISPLAY is obtained from the rk3288. For example, execute instruction echo $DISPLAY on RK3288.
      <img src="/wiki/images/3/3b/RK3288_Qt_debug_DISPLAY.png" _fck_mw_filename="RK3288 Qt debug DISPLAY.png" _fck_mw_origimgwidth="1372" _fck_mw_origimgheight="740" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />
    5. Switch to "Edit" mode
    6. Click "Build" using context menu of project "Hello"
      <img src="/wiki/images/4/47/RK3288_Qt_code_build.png" _fck_mw_filename="RK3288 Qt code build.png" _fck_mw_origimgwidth="1375" _fck_mw_origimgheight="747" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />
    7. The green "Build" bar means no error occured.
      <img src="/wiki/images/5/5c/RK3399_Qt_build_status.png" _fck_mw_filename="RK3399 Qt build status.png" _fck_mw_origimgwidth="996" _fck_mw_origimgheight="28" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />
    8. Press "Alt+4" to show "Compile Output".
      <img src="/wiki/images/b/b1/RK3288_Qt_build_output.png" _fck_mw_filename="RK3288 Qt build output.png" _fck_mw_origimgwidth="1372" _fck_mw_origimgheight="740" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />

      </dd></dl></li></ol>

      Deploying the Application

      1. Click "Deploy" using context menu of project hello_qt
        <img src="/wiki/images/7/75/RK3288_Qt_deploy_start.png" _fck_mw_filename="RK3288 Qt deploy start.png" _fck_mw_origimgwidth="1375" _fck_mw_origimgheight="743" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />
      2. The green "Deploy" bar indicates no error occured.
        <img src="/wiki/images/3/32/RK3288_Qt_deploy_output.png" _fck_mw_filename="RK3288 Qt deploy output.png" _fck_mw_origimgwidth="1065" _fck_mw_origimgheight="403" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />
        </dd></dl></li></ol>

        Debugging the Application

        1. Click debug icon to start debugging.
          <img src="/wiki/images/3/36/RK3288_Qt_debug_icon.png" _fck_mw_filename="RK3288 Qt debug icon.png" _fck_mw_origimgwidth="72" _fck_mw_origimgheight="213" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />
        2. Press "Alt+3" to show "Application Output"
          <img src="/wiki/images/0/06/RK3288_Qt_debug_output.png" _fck_mw_filename="RK3288 Qt debug output.png" _fck_mw_origimgwidth="1061" _fck_mw_origimgheight="399" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />
          </dd></dl></li>
        3. The "hello_qt" shows up on primary display.
          <img src="/wiki/images/a/ac/RK3399_Qt_result_show.png" _fck_mw_filename="RK3399 Qt result show.png" _fck_mw_origimgwidth="404" _fck_mw_origimgheight="327" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />
        4. Click "stop" to stop debugging.
          <img src="/wiki/images/8/8d/RK3288_Qt_debug_stop.png" _fck_mw_filename="RK3288 Qt debug stop.png" _fck_mw_origimgwidth="461" _fck_mw_origimgheight="61" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />
        5. The deafult desktop returns back.
          <img src="/wiki/images/6/60/RK3399_Qt_default_Desktop.png" _fck_mw_filename="RK3399 Qt default Desktop.png" _fck_mw_origimgwidth="1280" _fck_mw_origimgheight="720" alt="RTENOTITLE" title="RTENOTITLE" style="vertical-align:middle;" />
          </dd></dl></li></ol>