running the code as root on Qt-Creator SDK

前端 未结 2 1626
长情又很酷
长情又很酷 2021-01-13 16:00

I use Qt-Creator 2.5.2 SDK to develop C code on Linux. How is it possible to run the codes as root when it is run from the SDK interface (e.g., ctrl + R)?

相关标签:
2条回答
  • 2021-01-13 16:51

    Most simple solution to run Qt-Creator as root

    Honestly thats not a trivial task (as long as I tried to do it myself while ago). Are you sure you really need to run debug under root? If it's about access to some device nodes, may be it's easier to adjust rights on them?

    Another solution (keeping QT creator running under user account can be something like)

    adjust sudoers (/etc/sudoers)

     <user> <machine>= NOPASSWD: /usr/bin/gdb
    

    then make a wrapper script something like /usr/bin/sudo-gdb:

     #!/bin/bash
     sudo gdb $@
    

    Then instruct QT Creator use sudo-gdb as debugger.

    0 讨论(0)
  • 2021-01-13 16:54

    The following actions were recommended on Qt support forum:

    In Qt Creator, add remote Linux device in Options -> Devices. Set its address as localhost and user as root. Create a pair of authentication keys and paste public key to /root/.ssh/authorized_keys. Then clone Desktop kit in Options -> Kits and set the device for new kit to the device you've created on previous step.

    Now, when you start debugging, Qt Creator should automatically connect over ssh to localhost as root, start gdbserver and perform debugging.

    It works for running without debugging too.

    Perhaps you should set up installation of your program on remote host, but that's a different story and it's done differently for Qmake and QBS.

    https://forum.qt.io/post/185983

    0 讨论(0)
提交回复
热议问题