How to remotely debug graphic application with QtC

2019-08-06 09:12发布

I develop a cross-platform Qt application. And now I need/want to run it on a remote host with GUI form loading.
I know 2 ways to do that:

  • open application on a remote display (may be virtual) with console attached to QtCreator via ssh
  • run with remote X session, like it done with ssh -X or -Y.

When I run an application through QtCreator on the remote device it says

QXcbConnection: Could not connect to display

When I connect to remote host with ssh -Y and run my app, it says

QXcbConnection: Could not connect to display localhost:10.0
Aborted

On my local host and on remote host via VNC the application works fine.

ssh -Y user@host xclock also works fine - opens it's form on my local display.

Host system is Ubuntu 16.04 LTS x64, target system Ubuntu 16.04 LTS x86 32bit. Qt version 5.9.1

Please help me to make it work. In worst case I agree to see debug console in and gdb attached to QtCreator, but the GUI could still be placed on a remote display.


Update: Here is related question on form.qt.io.

1条回答
劳资没心,怎么记你
2楼-- · 2019-08-06 09:32

After some research and help from QtCreator community I found
The way is simple:

  1. Open ssh session to remote host with X forwarding enabled ssh -X user@host. And get know the DISPLAY variable. For example with echo $DISPLAY. It should look like localhost:10.0.
  2. Set environment variable DISPLAY in QtCreator -> Projects -> YourConfiguration -> Run -> RunEnvironment to known value from (1).
  3. Run and enjoy remote debug with GUI on local machine.

Note: closing ssh session will make forwarded display inaccessible and invalid.

查看更多
登录 后发表回答