Qt Creator code as a user but run and debug as root

大城市里の小女人 提交于 2019-12-01 23:28:34

WiringPi does not need root access. You need to set properties to the relevant device nodes properly, that's all. Make sure you have /dev/gpiomem available for use by WiringPi, writable by the user. It's available on 4.1 and newer kernels IIRC.

Your question is a case of an X-Y problem. Yes, root access sidesteps the problem of wrong device node properties, but it's not a proper solution at all. Don't run your application as root.

The short answer is no. Even if you could start the application to run as root from within a non-root QtCreator context, you would not be able to connect to the running process and debug it.

You are better off just running QtCreator as root.

If you need to develop a "user mode" interface to the GPIO pins, you can try this tutorial: LED Driver

It shows a way to create nodes within the /sys tree that can give you usermode access to the GPIO.

iGian

I solved today the same issue with wiringPi following this comment: https://askubuntu.com/a/711130

In my case it was:

Tools-> Options-> Environment replaced the default string with "/usr/bin/xterm -e sudo" in terminal option.

Also, do not forget to go to Projects > Build & Run > Run and check the box Run in terminal.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!