How to remotely debug Qt applications: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
(Removed cleanup notice)
(Expanded Virtualbox instructions, added qt installation, deploy does not work yet,)
Line 3: Line 3:


== Introduction ==
== Introduction ==
Warning: this guide is not finished, the remote deploy step throws an error.
This is a guide to write a Qt program on one virtual PC, and deploy and debug it on another virtual PC. As a first step, both virtual PC's are running linux. this guide assumes a windows 7 host system, but this should work on each platform that can run Virtualbox.
This is a guide to write a Qt program on one virtual PC, and deploy and debug it on another virtual PC. As a first step, both virtual PC's are running linux. this guide assumes a windows 7 host system, but this should work on each platform that can run Virtualbox.
=== Master ===
This PC will be running the Qt IDE. This is where you will write the Qt program.
=== Target ===
This PC will be the target. This is where the Qt program will run. This PC has almost nothing installed, no IDE, no compilers, just a runtime


== Setting up the virtual machines ==
== Setting up the virtual machines ==
Line 16: Line 24:


=== Install Ubuntu on both virtual machines ===
=== Install Ubuntu on both virtual machines ===
Start Virtualbox, Select 'ubuntu-master', click run. In a new window 'Ubuntu-master [running]', ubuntu should boot from CD. On my PC, the installer does not react to the mouseclicks, so use the tab, space and return keys to make the selections.  Choose "Install Ubuntu". Select "Download updates while installing" and select "Install this third-party software". Choose "Erase disk and install ubuntu", and "Install Now", and "Continue". Next select your location, and choose "Continue". Next choose a keyboard layout and "Continue". Next choose a name and password. Choose "Master" as the computer name, and select "log in automatically", and choose "Continue", after some time, choose "Restart Now". After some time the desktop is loaded.
==== Internet connection ====
Open a terminal (click top-left, search terminal). Check your internet connection with the following command:
$ ping www.google.com
...64 bytes from ... time ..ms
$ route
Destination Gateway
... default 10.0.2.2
Next click on the top-left networking icon, and choose "Connection information". Wired connection 1 is active, and has the default route 10.0.2.2
==== VirtualLAN connection ====
Click on the top-left networking icon, and choose "Edit connections" Select Wired connection 2, and choose edit. Select IPv4 Settings, and enter the following information:
Method: Manual
Addresses: 192.168.107.1
Netmask: 255.255.255.0
Gateway: 0.0.0.0
DNS servers: <empty>
search domains: <empty>
Next press "save"
Click on the top-left networking icon, and choose "Wired connection 2 disconnect", and then "Wirend connection 2". Now the new settings for wired connection 2 are active.
=== Clone the master virual machine to create the target ===
Shut down the master virtual PC. Next goto Virtual Box, and select ubuntu-master. Now choose Machine-clone, and set the name to ubuntu-target. Also enable "Reinitialize the MAC address of all network cards", and choose next. Choose "Linked clone", and clone
http://www.sysprobs.com/linked-clone-virtualbox-how-to-clone-virtual-machine
==== Setting up the target machine ====
Start Virtualbox, Select 'ubuntu-target', click run. After some time the desktop is loaded. Click system settings-Details. Change the device name from "Master" to "Target". Next logout and login, to let the new machine name take effect.
Click on the top-left networking icon, and choose "Edit connections" Select Wired connection 2, and choose edit. Select IPv4 Settings, and enter the following information:
Method: Manual
Addresses: 192.168.107.2
Netmask: 255.255.255.0
Gateway: 0.0.0.0
DNS servers: <empty>
search domains: <empty>
Next press "save"
Click on the top-left networking icon, and choose "Wired connection 2 disconnect", and then "Wirend connection 2". Now the new settings for wired connection 2 are active.
=== Testing the Virtual Lan connection===
Start both the ubuntu-master and the ubuntu-target machine.  On the master, enter the following command to ping the target:
$ ping 192.168.107.2
On the slave, enter the following command to ping the master:
$ping 192.168.107.1
== Install Qt on the master PC ==
Start ubuntu software center. Search for qt-sdk, select it, and press install. next type in your password. After some time Qtcreator is installed.
== remote debug the application ==
Start both the master and the target virtual machine.
=== Create a new project on the master ===
On the master start Qt Creator. Select new project-applications-QT Widgets Application-choose. Pick a name and a location, and click next. select the kit "Desktop", and click next. Choose the names for the classed etc, and press next. Choose <None> for version control, and press finish.
=== Connect to the target ===
In Qt Creator, Click on projects at the left side. Then click Manage Kits... This will open the options screen. Then select devices, and click Add... Generic Linux Device, start wizzard. Enter the following settings:
Name: ubuntu-target
IP: 192.168.107.2
User: <your username>
authentication type: password
password: <your password>
choose next and finish. Now the error "SSH connection failure: Connection refused" comes up. Click close


on ubuntu-target, start ubuntu software center. Search for openssh-server, and install it.


=== Master ===
on ubuntu-master, select ubuntu-target, and click test. Now the device test succeeds. Click close and OK.
This PC will be running the Qt IDE. This is where you will write the Qt program.
=== Deploy to the target===
In Qt Creator on ubuntu-master, click projects, Manage Kits... This will open the options screen. Now click Build & Run, Kits, Add. Enter the following settings:
name: ubuntu-target
Device type: generic linux device
Device: ubuntu-target
Sysroot: <empty>
Compiler GCC (x86 32 bit in /usr/bin)
Debugger: System GDB
Qt version: Qt 5.4.1
Click OK
In projects-untiteld-Build & Run click add Kit-ubuntu-target.
In Qt creator click the little arrow next to debug, and select ubuntu-target debug. Now click the green arrow with the bug on top (Start Debugging)
Launching gives the error "Initial setup failed: Application finished with exit code 1"


=== Target ===
Application output shows the following error:
This PC will be the target. This is where the Qt program will run. This PC has almost nothing installed, no IDE, no compilers, just a runtime
"
Cannot exec : no such file or directory
"

Revision as of 05:42, 29 July 2015

En Ar Bg De El Es Fa Fi Fr Hi Hu It Ja Kn Ko Ms Nl Pl Pt Ru Sq Th Tr Uk Zh

Introduction

Warning: this guide is not finished, the remote deploy step throws an error.

This is a guide to write a Qt program on one virtual PC, and deploy and debug it on another virtual PC. As a first step, both virtual PC's are running linux. this guide assumes a windows 7 host system, but this should work on each platform that can run Virtualbox.

Master

This PC will be running the Qt IDE. This is where you will write the Qt program.

Target

This PC will be the target. This is where the Qt program will run. This PC has almost nothing installed, no IDE, no compilers, just a runtime

Setting up the virtual machines

download needed files

Download Virtual box and VirtualBox Extension Pack from this site: http://dlc-cdn.sun.com/virtualbox/4.3.28/index.html This tutorial has been tested with virtualbox 4.3.28. Next download Ubuntu from this site: http://www.ubuntu.com/download/desktop This tutorial has been tested with 15.04 32bit.

Install Virtualbox

In windows, open VirtualBox-4.3.28-100309-Win.exe, and accept the defaults. Also accept the 4 prompts about device software installation. Then install Oracle_VM_VirtualBox_Extension_Pack-4.3.28-100309.vbox-extpack by double-clicking the file. Then click install, scroll down the PUEL, and click 'I agree'

Create the virtual machines, with a virtual network between them

Start Virtualbox, click file-preferences-general. Set the default Machine Folder to a spacious location. Next click machine-new, set the name to Ubuntu-master, type linux, version Ubuntu (32 bit), next Set memory size to 1024MB, next, create a virtual hard drive now, create, VDI, next, Dynamically allocated, next, select size: 50BG. Select Ubuntu master, then click Settings-storage-CD icon-choose a virtual CD/DVD file... Then browse to ubuntu-15.04-desktop-i386.iso, and click open. Select Network, Adapter2, enable adapter, attached to internal network, name "virtualLAN". click OK. Select Ubuntu-master, click machine-clone. New machine name: Ubuntu-target, next clone type=Full clone, clone

Install Ubuntu on both virtual machines

Start Virtualbox, Select 'ubuntu-master', click run. In a new window 'Ubuntu-master [running]', ubuntu should boot from CD. On my PC, the installer does not react to the mouseclicks, so use the tab, space and return keys to make the selections. Choose "Install Ubuntu". Select "Download updates while installing" and select "Install this third-party software". Choose "Erase disk and install ubuntu", and "Install Now", and "Continue". Next select your location, and choose "Continue". Next choose a keyboard layout and "Continue". Next choose a name and password. Choose "Master" as the computer name, and select "log in automatically", and choose "Continue", after some time, choose "Restart Now". After some time the desktop is loaded.

Internet connection

Open a terminal (click top-left, search terminal). Check your internet connection with the following command:

$ ping www.google.com

...64 bytes from ... time ..ms

$ route

Destination Gateway ... default 10.0.2.2

Next click on the top-left networking icon, and choose "Connection information". Wired connection 1 is active, and has the default route 10.0.2.2

VirtualLAN connection

Click on the top-left networking icon, and choose "Edit connections" Select Wired connection 2, and choose edit. Select IPv4 Settings, and enter the following information: Method: Manual Addresses: 192.168.107.1 Netmask: 255.255.255.0 Gateway: 0.0.0.0 DNS servers: <empty> search domains: <empty> Next press "save" Click on the top-left networking icon, and choose "Wired connection 2 disconnect", and then "Wirend connection 2". Now the new settings for wired connection 2 are active.

Clone the master virual machine to create the target

Shut down the master virtual PC. Next goto Virtual Box, and select ubuntu-master. Now choose Machine-clone, and set the name to ubuntu-target. Also enable "Reinitialize the MAC address of all network cards", and choose next. Choose "Linked clone", and clone http://www.sysprobs.com/linked-clone-virtualbox-how-to-clone-virtual-machine

Setting up the target machine

Start Virtualbox, Select 'ubuntu-target', click run. After some time the desktop is loaded. Click system settings-Details. Change the device name from "Master" to "Target". Next logout and login, to let the new machine name take effect. Click on the top-left networking icon, and choose "Edit connections" Select Wired connection 2, and choose edit. Select IPv4 Settings, and enter the following information: Method: Manual Addresses: 192.168.107.2 Netmask: 255.255.255.0 Gateway: 0.0.0.0 DNS servers: <empty> search domains: <empty> Next press "save" Click on the top-left networking icon, and choose "Wired connection 2 disconnect", and then "Wirend connection 2". Now the new settings for wired connection 2 are active.

Testing the Virtual Lan connection

Start both the ubuntu-master and the ubuntu-target machine. On the master, enter the following command to ping the target: $ ping 192.168.107.2 On the slave, enter the following command to ping the master: $ping 192.168.107.1

Install Qt on the master PC

Start ubuntu software center. Search for qt-sdk, select it, and press install. next type in your password. After some time Qtcreator is installed.

remote debug the application

Start both the master and the target virtual machine.

Create a new project on the master

On the master start Qt Creator. Select new project-applications-QT Widgets Application-choose. Pick a name and a location, and click next. select the kit "Desktop", and click next. Choose the names for the classed etc, and press next. Choose <None> for version control, and press finish.

Connect to the target

In Qt Creator, Click on projects at the left side. Then click Manage Kits... This will open the options screen. Then select devices, and click Add... Generic Linux Device, start wizzard. Enter the following settings: Name: ubuntu-target IP: 192.168.107.2 User: <your username> authentication type: password password: <your password> choose next and finish. Now the error "SSH connection failure: Connection refused" comes up. Click close

on ubuntu-target, start ubuntu software center. Search for openssh-server, and install it.

on ubuntu-master, select ubuntu-target, and click test. Now the device test succeeds. Click close and OK.

Deploy to the target

In Qt Creator on ubuntu-master, click projects, Manage Kits... This will open the options screen. Now click Build & Run, Kits, Add. Enter the following settings: name: ubuntu-target Device type: generic linux device Device: ubuntu-target Sysroot: <empty> Compiler GCC (x86 32 bit in /usr/bin) Debugger: System GDB Qt version: Qt 5.4.1 Click OK In projects-untiteld-Build & Run click add Kit-ubuntu-target. In Qt creator click the little arrow next to debug, and select ubuntu-target debug. Now click the green arrow with the bug on top (Start Debugging) Launching gives the error "Initial setup failed: Application finished with exit code 1"

Application output shows the following error: " Cannot exec : no such file or directory "