IoTGateway/BSP/Linux

From ESS-WIKI
Revision as of 01:41, 3 April 2024 by Shenghang.lei (talk | contribs) (Installing cross toolchain)
Jump to: navigation, search

Preface

Qt has many versions, and may run on defferent OSs.But the toolchain we provide can fit them well.

It has the following advantages:

  • The compilation environment is consistent with runtime environment.
  • Good compatibility.
  • Good extensibility.

So the application compiled by the toolchain can run perfectly on our products. And the toolchain can be used on Debian or Ubuntu Desktop Operating System well.

If you meet any problems, please do not hesitate to contact Advantech for help.

Prerequisites

Kylin-Enbeded-V10.

Installing required packages

Please login and perform the following commands:

$ sudo apt-get install -y build-essential 
$ sudo apt-get install -y qtcreator 
$ sudo apt-get install -y qt5-default 
$ sudo apt-get install -y qt5-doc 
$ sudo apt-get install -y qt5-doc-html qtbase5-doc-html 
$ sudo apt-get install -y qtbase5-examples 
$ sudo apt-get install -y qt5-qmake 
$ sudo apt-get install -y rsync
$ sudo apt-get install -y gcc-8-arm-linux-gnueabihf g++-8-arm-linux-gnueabihf
$ sudo apt-get install -y gcc-8-aarch64-linux-gnu g++-8-aarch64-linux-gnu

Link arm-linux-gnu*-8 to arm-linux-gnu* and aarch64-linux-gnu*-8 to aarch64-linux-gnu*:

$ sudo su
$ cd /usr/bin
$ for f in $(ls arm-linux-gnu*-8);do ln -sf $f $(echo $f|sed "s/-8//");done 
$ for f in $(ls aarch64-linux-gnu*-8);do ln -sf $f $(echo $f|sed "s/-8//");done
$ exit

 

Installing cross toolchain

Please download cross compiler toolchain first.

ITB202(Password:kroa )

Then execute the following command to unzip the cross compiler tool to the /opt directory

For ITB202

$ sudo rm -rf /opt/toolchain_Qt_V5.12.12/itb202/ 
$ sudo mkdir -p /opt/toolchain_Qt_V5.12.12/itb202/ 
$ sudo tar -xvf itb202_toolchain_Qt_V5.12.12_*.tar.gz -C /opt/toolchain_Qt_V5.12.12/itb202/

Working within QtCreator

The following example is test on QT5.12.12(qmake version) of Ubuntu18.04.There may be a few differences on other operating system,but the main steps are the same.

Use qtcreator to configure a complete build kit.

Config QtCreator ---- Qt Versions

1. Select Tools --> options --> 

RTENOTITLE

2. Select Qt versions --> Manual -->Add -->

    Path:/opt/toolchain_Qt_V5.12.12/itb202/sysroot/qmake


Qt version1.png Qt version2.png

Config QtCreator ---- Qt Complers

1. Select compilers -->

2. Because Gcc and G++ has been installed earlier, the compiler will generally detect it automatically.

    If no Auto-detected, just Add it.

Path forRK3588 (64):/usr/bin/arrch64-linux-gnu-gcc         

                                   /usr/bin/aarch64-linux-gnu-g++


The following figure uses ITB202  as an example :

RTENOTITLE

Config QtCreator ---- Qt Debuggers

1. Select Debuggers -->

2. The Debuggers selection system buildin,If no Auto-detected , just Add it:

    Path: /usr/bin/gdb

RTENOTITLE

Config QtCreator ---- Qt Cmakes

1. Select Cmake -->

2. Similarly,Cmake also uses the system Cmake , if no Auto-detected , just Add it :

    Path: /usr/bin/Cmake

RTENOTITLE

Config QtCreator ---- Qt kits

1. Select Kits 

2. Configure "Qt version"、"Compilers"、"Debuggers" and "Cmake" configurations in Kits.

     The picture below uses ITB202 as an example:

Qt kit 1.png Qt kit2.png

Creating the Project

  1. Bring up "New" dailog using "File" -> "New File or Project..."
  2. Select "Applications" -> 'Qt Widgets Application"
  3. Click "Choose..."
    RTENOTITLE
  4. Use "Hello" as name
  5. Create in "/mnt/sda1/work/qt/qt_PJ"
  6. Click "Next"
    RTENOTITLE
  7. Check "RK toolchain"
  8. Click "Next".
    RTENOTITLE
  9. Use default settings for "Class Information"
  10. Click "Next"
    RTENOTITLE
  11. Use default settings for "Project Management"
  12. Click "Finish"
    RTENOTITLE
  13. Double click "Hello.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
    RTENOTITLE
  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
    RTENOTITLE
    RTENOTITLE
  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".
    RTENOTITLE
  3. Check if "Files to deploy" is correct
    RTENOTITLE
  4. Set environment variable DISPLAY in QtCreator -> Projects -> Run -> Run Environment. The value of DISPLAY is obtained from the rk3399. For example, execute instruction echo $DISPLAY on RK3399.
    RTENOTITLE
  5. Switch to "Edit" mode
  6. Click "Build" using context menu of project "Hello"
    RTENOTITLE
  7. The green "Build" bar means no error occured.
    RTENOTITLE
  8. Press "Alt+4" to show "Compile Output". RTENOTITLE

Deploying the Application

  1. Click "Deploy" using context menu of project HelloRTENOTITLE
  2. The green "Deploy" bar indicates no error occured.RTENOTITLE

Debugging the Application

  1. Click debug icon to start debugging.
    RTENOTITLE
  2. Press "Alt+3" to show "Application Output"RTENOTITLE
  3. The "Hello" shows up on primary display.
    RTENOTITLE
  4. Click "stop" to stop debugging.
    RTENOTITLE
  5. The default desktop returns back.RTENOTITLE

FAQ

Cannot find Libraries

When build, you may get the error like "cannot find -lxxxx".

"xxxx" is just an example of the library linked to your application.

For example: "cannot find -lsqlite3"

First find the library in toolchain path.

The following commands are taking "RK3568 libsqlite3" as example, other platforms are very similar.

cd /opt/toolchain_Qt_V5.11.3/rk3568/
find ./ -name libsqlite3.so*
cd ./sysroot/usr/lib/aarch64-linux-gpu
or
cd ./sysroot/lib/aarch64-linux-gpu
ln -s libsqlite3.so.0 libsqlite3.so

If you cannot find the library you need in toolchain path, please do not hesitate to contact Advantech for help.