Article directory
background
When debugging programs under Linux, sometimes you need to obtain root permissions to connect and operate certain devices.
Before, I did it through scripting [executing custom commands in QtCreator first and then executing the program] . That is to obtain permissions in the script, the content of the script is similar to this:
echo "mypwd" | sudo -S -E LD_LIBRARY_PATH=$LD_LIBRARY:/home/yong/Desktop/two_axis/libIR/x86-linux_libs ./TemperatureMonitor
But there is a problem with this. Breakpoint debugging cannot be done. If something goes wrong, it is difficult to find where the problem occurs.
But if you don't use a script, but start its default executable program + check Run as root user, it will cause an error while loading shared libraries.
Even if you have set the environment variable LD_LIBRARY_PATH.
Solution
Now with the latest version of QtCreator 11.0.1, the solution is simple. Just check Run in terminal as well.
Then enter your password in the console.
Other solutions
In the old version of QtCreator, you can only see whether you can change the permissions of the operation object so that non-root users can also operate it. For example, execute chmod or something.