Difference between revisions of "IoTGateway/BSP/Linux"
(kylinos QT) |
|||
Line 1: | Line 1: | ||
− | + | = 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 = |
− | + | <span style="color:#FF0000;">Debian10(buster) is highly recommended OS to develop.</span> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | == | + | == Installing required packages == |
− | + | Please login and perform the following commands: | |
− | + | <pre>$ 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 | |
− | + | </pre> | |
− | + | Link arm-linux-gnu*-8 to arm-linux-gnu* and aarch64-linux-gnu*-8 to aarch64-linux-gnu*: | |
+ | <pre>$ 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 | ||
− | + | </pre> | |
− | + | | |
− | == | + | == Installing cross toolchain == |
− | + | Please download cross compiler toolchain first. | |
− | + | [https://pan.baidu.com/s/1JnXJ_X_HRDWoB14VBIq9fA RK3288](Password: gm9i) | |
− | + | [https://pan.baidu.com/s/1OEzbJsgBSo3n5DdwRY2Rag RK3399](Password: 0kkn) | |
− | + | [https://pan.baidu.com/s/17hCuIcORYDPOSAqVoyPPrg RK3568](Password: a887) | |
− | |||
− | |||
− | + | [https://pan.baidu.com/s/1KWoDVtQhAEJTi_1GiAcC0A RK3588](Password: a887) | |
− | |||
− | |||
− | |||
− | + | Then execute the following command to unzip the cross compiler tool to the /opt directory | |
− | + | For RK3288 | |
− | + | <pre>$ sudo rm -rf /opt/toolchain_Qt_V5.11.3/rk3288/ | |
− | + | $ sudo mkdir -p /opt/toolchain_Qt_V5.11.3/rk3288/ | |
− | + | $ sudo tar -zxf rk3288_toolchain_Qt_V5.11.3_*.tar.gz -C /opt/toolchain_Qt_V5.11.3/rk3288/ | |
− | + | </pre> | |
− | * | ||
− | |||
− | |||
− | |||
− | |||
− | + | For RK3399 | |
+ | <pre>$ sudo rm -rf /opt/toolchain_Qt_V5.11.3/rk3399/ | ||
+ | $ sudo mkdir -p /opt/toolchain_Qt_V5.11.3/rk3399/ | ||
+ | $ sudo tar -zxvf rk3399_toolchain_Qt_V5.11.3_*.tar.gz -C /opt/toolchain_Qt_V5.11.3/rk3399/ | ||
+ | </pre> | ||
− | + | For RK3568 | |
+ | <pre>$ sudo rm -rf /opt/toolchain_Qt_V5.11.3/rk3568/ | ||
+ | $ sudo mkdir -p /opt/toolchain_Qt_V5.11.3/rk3568/ | ||
+ | $ sudo tar -zxf rk3568_toolchain_Qt_V5.11.3_*.tar.gz -C /opt/toolchain_Qt_V5.11.3/rk3568/</pre> | ||
− | * | + | For RK3588 |
+ | <pre>$ sudo rm -rf /opt/toolchain_Qt_V5.15.2/rk3588/ | ||
+ | $ sudo mkdir -p /opt/toolchain_Qt_V5.15.2/rk3588/ | ||
+ | $ sudo tar -zxf rk3588_toolchain_Qt_V5.15.2_*.tar.gz -C /opt/toolchain_Qt_V5.15.2/rk3588/</pre> | ||
− | = | + | = Working within QtCreator = |
− | + | The following example is test on QT5.9.5(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 --> | |
− | : | + | [[File:QtDNK5.png|RTENOTITLE]] |
− | + | 2. Select Qt versions --> Manual -->Add --> | |
− | : | + | Path:/opt/toolchain_Qt_V5.11.3/<span style="color:#FF0000;">'''RK3568 or RK3399 or RK3288'''</span><span style="color:#000000;">/sysroot/qmake</span> |
− | < | ||
− | |||
− | < | ||
− | </ | ||
− | : | + | Path:/opt/toolchain_Qt_V5.15.2/<span style="color:#FF0000;">'''RK3588'''</span><span style="color:#000000;">/sysroot/qmake</span> |
− | :: | ||
− | + | [[File:QtICMN.png|RTENOTITLE]] | |
− | + | [[File:QtLZHW4.png|RTENOTITLE]] | |
− | + | == 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. | |
− | + | <span style="color:#000000;">'''Path for'''</span><span style="color:#ff0000;">'''RK3588 (64)'''</span><span style="color:#000000;">:/usr/bin/arrch64-linux-gnu-gcc </span> | |
− | + | /usr/bin/aarch64-linux-gnu-g++ | |
− | = ''' | + | <span style="color:#000000;">'''Path for'''</span><span style="color:#ff0000;">'''RK3568 (64)'''</span><span style="color:#000000;">:/usr/bin/arrch64-linux-gnu-gcc </span> |
− | + | /usr/bin/aarch64-linux-gnu-g++ | |
− | + | | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | = ''' | + | <span style="color:#000000;">'''Path for'''</span><span style="color:#FF0000;">'''RK3399 (64)'''</span><span style="color:#000000;">:/usr/bin/aarch64-linux-gnu-gcc</span> |
− | + | /usr/bin/aarch64-linux-gnu-g++ | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
| | ||
− | = ''' | + | <span style="color:#000000;">'''Path for'''</span><span style="color:#FF0000;">'''RK3288(32)'''</span><span style="color:#000000;">:/usr/bin/arm-linux-gnueabihf-gcc</span> |
− | = | + | <span style="color:#FF0000;">''' '''</span><span style="color:#000000;">/usr/bin/arm-linux-gnueabihf-g++</span> |
− | + | The following figure uses rk3568 as an example : | |
+ | [[File:QtIXDKY6.png|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 | |
− | + | [[File:QtGZ6D5.png|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 | |
− | + | [[File:Qt8D.png|RTENOTITLE]] | |
− | + | == Config QtCreator ---- Qt kits == | |
− | + | 1. Select Kits | |
− | + | 2. Configure "Qt version"、"Compilers"、"Debuggers" and "Cmake" configurations in Kits. | |
− | + | The picture below uses rk3568 as an example: | |
− | + | [[File:T4KDS.png|RTENOTITLE]] | |
− | + | [[File:QtZ52.png|RTENOTITLE]] | |
− | + | == Creating the Project == | |
− | + | #Bring up "New" dailog using "File" -> "New File or Project..." | |
+ | #Select "Applications" -> 'Qt Widgets Application" | ||
+ | #Click "Choose..." | ||
+ | #;[[File:RK3399 Project 001.png|RTENOTITLE]] | ||
+ | #Use "Hello" as name | ||
+ | #Create in "/mnt/sda1/work/qt/qt_PJ" | ||
+ | #Click "Next" | ||
+ | #;[[File:RK3399 Qt Project local.png|RTENOTITLE]] | ||
+ | #Check "RK toolchain" | ||
+ | #Click "Next". | ||
+ | #;[[File:RK3399 Qt Project toolchain.png|RTENOTITLE]] | ||
+ | #Use default settings for "Class Information" | ||
+ | #Click "Next" | ||
+ | #;[[File:RK3399 QT Project last.png|RTENOTITLE]] | ||
+ | #Use default settings for "Project Management" | ||
+ | #Click "Finish" | ||
+ | #;[[File:RK3399 Qt Project last2.png|RTENOTITLE]] | ||
+ | #Double click "Hello.pro" to switch to editor window | ||
+ | #In new project it is necessary to add following two lines into qt project file. | ||
+ | #:<code>target.path = .<br/> INSTALLS += target</code> | ||
+ | #;[[File:RK3399 Qt Project code002.png|RTENOTITLE]] | ||
+ | #Press "Ctrl+S" to save file. | ||
+ | #Double click "mainwindow.ui" to switch to Design mode | ||
+ | #Drag & drop one Label widget on main form, use property editor on the right side to change text and font size | ||
+ | #;[[File:2015-01-30 174418.png|RTENOTITLE]] | ||
+ | #;[[File:RK3399 Qt Project code003.png|RTENOTITLE]] | ||
+ | #Save all project files using "File" -> "Save All" | ||
− | = | + | == Building the Project == |
− | + | #Switch to "Projects" mode | |
+ | #Check if "build configuration" is set to "Debug". | ||
+ | #;[[File:RK3399 Qt debug setting.png|RTENOTITLE]] | ||
+ | #Check if "Files to deploy" is correct | ||
+ | #;[[File:RK3399 Qt run setting.png|RTENOTITLE]] | ||
+ | #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. | ||
+ | #;[[File:RK3399 Qt ENV Display.png|RTENOTITLE]] | ||
+ | #Switch to "Edit" mode | ||
+ | #Click "Build" using context menu of project "Hello" | ||
+ | #;[[File:RK3399 Qt build start.png|RTENOTITLE]] | ||
+ | #The green "Build" bar means no error occured. | ||
+ | #;[[File:RK3399 Qt build status.png|RTENOTITLE]] | ||
+ | #Press "Alt+4" to show "Compile Output". [[File:RK3399 Qt build output.png|RTENOTITLE]] | ||
− | + | == Deploying the Application == | |
− | + | #Click "Deploy" using context menu of project Hello[[File:RK3399 Qt deploy start.PNG|RTENOTITLE]] | |
+ | #The green "Deploy" bar indicates no error occured.[[File:RK3399 Qt deploy output.png|RTENOTITLE]] | ||
− | + | == Debugging the Application == | |
− | |||
− | |||
− | + | #Click debug icon to start debugging. | |
+ | #;[[File:RK3399 Qt debug start.png|RTENOTITLE]] | ||
+ | #Press "Alt+3" to show "Application Output"[[File:RK3399 Qt debug output.png|RTENOTITLE]] | ||
+ | #The "Hello" shows up on primary display. | ||
+ | #;[[File:RK3399 Qt result show.png|RTENOTITLE]] | ||
+ | #Click "stop" to stop debugging. | ||
+ | #;[[File:RK3399 Qt debug stop.png|RTENOTITLE]] | ||
+ | #The default desktop returns back.[[File:RK3399 Qt default Desktop.png|RTENOTITLE]] | ||
− | + | = FAQ = | |
− | + | == Cannot find Libraries == | |
− | = | + | When build, you may get the error like "cannot find -l<span style="color:#d35400;">'''xxxx'''</span>". |
− | + | "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. | |
− | * | + | <pre>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 | ||
+ | </pre> | ||
− | + | If you cannot find the library you need in toolchain path, please do not hesitate to contact Advantech for help. |
Revision as of 11:17, 2 April 2024
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
Debian10(buster) is highly recommended OS to develop.
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.
RK3288(Password: gm9i)
RK3399(Password: 0kkn)
RK3568(Password: a887)
RK3588(Password: a887)
Then execute the following command to unzip the cross compiler tool to the /opt directory
For RK3288
$ sudo rm -rf /opt/toolchain_Qt_V5.11.3/rk3288/ $ sudo mkdir -p /opt/toolchain_Qt_V5.11.3/rk3288/ $ sudo tar -zxf rk3288_toolchain_Qt_V5.11.3_*.tar.gz -C /opt/toolchain_Qt_V5.11.3/rk3288/
For RK3399
$ sudo rm -rf /opt/toolchain_Qt_V5.11.3/rk3399/ $ sudo mkdir -p /opt/toolchain_Qt_V5.11.3/rk3399/ $ sudo tar -zxvf rk3399_toolchain_Qt_V5.11.3_*.tar.gz -C /opt/toolchain_Qt_V5.11.3/rk3399/
For RK3568
$ sudo rm -rf /opt/toolchain_Qt_V5.11.3/rk3568/ $ sudo mkdir -p /opt/toolchain_Qt_V5.11.3/rk3568/ $ sudo tar -zxf rk3568_toolchain_Qt_V5.11.3_*.tar.gz -C /opt/toolchain_Qt_V5.11.3/rk3568/
For RK3588
$ sudo rm -rf /opt/toolchain_Qt_V5.15.2/rk3588/ $ sudo mkdir -p /opt/toolchain_Qt_V5.15.2/rk3588/ $ sudo tar -zxf rk3588_toolchain_Qt_V5.15.2_*.tar.gz -C /opt/toolchain_Qt_V5.15.2/rk3588/
Working within QtCreator
The following example is test on QT5.9.5(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 -->
2. Select Qt versions --> Manual -->Add -->
Path:/opt/toolchain_Qt_V5.11.3/RK3568 or RK3399 or RK3288/sysroot/qmake
Path:/opt/toolchain_Qt_V5.15.2/RK3588/sysroot/qmake
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++
Path forRK3568 (64):/usr/bin/arrch64-linux-gnu-gcc
/usr/bin/aarch64-linux-gnu-g++
Path forRK3399 (64):/usr/bin/aarch64-linux-gnu-gcc
/usr/bin/aarch64-linux-gnu-g++
Path forRK3288(32):/usr/bin/arm-linux-gnueabihf-gcc
/usr/bin/arm-linux-gnueabihf-g++
The following figure uses rk3568 as an example :
Config QtCreator ---- Qt Debuggers
1. Select Debuggers -->
2. The Debuggers selection system buildin,If no Auto-detected , just Add it:
Path: /usr/bin/gdb
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
Config QtCreator ---- Qt kits
1. Select Kits
2. Configure "Qt version"、"Compilers"、"Debuggers" and "Cmake" configurations in Kits.
The picture below uses rk3568 as an example:
Creating the Project
- Bring up "New" dailog using "File" -> "New File or Project..."
- Select "Applications" -> 'Qt Widgets Application"
- Click "Choose..."
- Use "Hello" as name
- Create in "/mnt/sda1/work/qt/qt_PJ"
- Click "Next"
- Check "RK toolchain"
- Click "Next".
- Use default settings for "Class Information"
- Click "Next"
- Use default settings for "Project Management"
- Click "Finish"
- Double click "Hello.pro" to switch to editor window
- In new project it is necessary to add following two lines into qt project file.
- Press "Ctrl+S" to save file.
- Double click "mainwindow.ui" to switch to Design mode
- Drag & drop one Label widget on main form, use property editor on the right side to change text and font size
- Save all project files using "File" -> "Save All"
Building the Project
- Switch to "Projects" mode
- Check if "build configuration" is set to "Debug".
- Check if "Files to deploy" is correct
- 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.
- Switch to "Edit" mode
- Click "Build" using context menu of project "Hello"
- The green "Build" bar means no error occured.
- Press "Alt+4" to show "Compile Output".
Deploying the Application
- Click "Deploy" using context menu of project Hello
- The green "Deploy" bar indicates no error occured.
Debugging the Application
- Click debug icon to start debugging.
- Press "Alt+3" to show "Application Output"
- The "Hello" shows up on primary display.
- Click "stop" to stop debugging.
- The default desktop returns back.
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.