QTCREATOR Cross compile and debug ARM device

Post Reply
marius
Site Admin
Posts: 18
Joined: Tue Sep 10, 2019 2:21 pm

QTCREATOR Cross compile and debug ARM device

Post by marius » Tue Oct 08, 2019 9:31 pm

Prerequisites:

On PC:
  • qt5 git clone git://code.qt.io/qt/qt5.git
  • I use this one gcc-linaro-6.4.1-2017.11-x86_64_arm-linux-gnueabihf :(
  • qtcreator 4.9.1 Based on 5.12.3 Not from Linux repos. Is installed from qt-everywhere binary from QT :shock:
Setup:
A base folder for the whole damn thing. Let's call this SDK root.
We make in SDK root couple of folders

Code: Select all

SDK/
  /debfs                                      # we rsync here the root fs
  /qt5                                          # we clone here qt5 and 
  /gcc-linaro-6.4.1-2017.11-x86_64_arm-linux-gnueabihf  # we untar here the toochain
  
  # for qt5 
  git clone git://code.qt.io/qt/qt5.git
  cd qt5
  git checkout 5.12
  git submodule update --init --recursive 
Configuring QtCreator and the target for debugging

On ARM Target (We use beaglebone)
  • setup ssh using key authentication so no password would be required to login
  • install gdb server
QtCreator

The concept

Image
  • Add a device Menu Options Devices
Image

Image

Image

Image


Add the compilers C and C++ from the tollchain path

Image

Image

Add the debugger
Image

  • Kits, you might see an error (red)
Image
  • Goto qt versions. Select the qt version from cloned qt5 as shown
Image
  • Then in kits, select the version and make toll as shown. You have to install on PC cmake (optional) the red/yellow mark should go away.
Image
  • If you already y have a project (pro) exit qtstudio and delete the *.pro.user file from project folder. Start qt and reload the project. Select configurations including the ARM kit as shown
Image
  • When debugging make sure you select
Image


Tweaks.
  • Open *.pro file and add this line above SOURCES

Code: Select all

QMAKE_LFLAGS += "-Wl,-rpath-link,/FULL_PATH_TO/SDK/debfs/lib/arm-linux-gnueabihf,-rpath-link,/FULL_PATH_TO/SDK/debfs/usr/lib/arm-linux-gnueabihf"

  • If you have dependent libraries you build. I have you might add these in qmake pro file as:
    Check what PREFIX or CC or TCC make files are using to select the compiler.
If not make some changes as:

Code: Select all


UNAME := $(shell uname)
GCC=gcc
ifeq ($(UNAME), Linux)
	COMP=gcc
endif
ifeq ($(UNAME), FreeBSD)
	COMP=c++
endif

GCC=$(PREFIX)$(COMP)


In pro file

Code: Select all

system('export PREFIX=arm-linux-gnueabihf- && cd somefilder && make && cd backtothisfolder')
system('export PREFIX=arm-linux-gnueabihf- && cd somefilder && make && cd backtothisfolder)
  • Save, Menu->Build->Run qmake
    Then compile
in the COmpile out pane at th ebottom of IDE the arm comoiler should be invoked.

Code: Select all

arm-linux-gnueabihf-g++ -c -pipe -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mthumb -fPIC -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mthumb -fPIC -mfloat-abi=hard --sysroot=/home/marius/HOMEBOARDS/BBG_S2W/debfs -std=c++14 -g -O0 -Wno-unused-parameter -Wall -W -D_REENTRANT -fPIC -DDEBUG -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -I../embix -I. -I../embix/plugins -I../embix/sq/include -I../embix/sq/squirrel -I../embix/sq/sqrat/include -I../embix/sq/sqrat -I../embix/sq/sqrat/include/sqrat -I../../HOMEBOARDS/BBG_S2W/qt5/qtbase/mkspecs/devices/linux-beagleboard-g++ -o main.o ../embix/main.cpp
Have a break-point. Start the debugger,

Image

On the target you can see the gdb process and the app being debugged

Image


Thx for reading.

Post Reply