Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It is possible to run my application with root priviliges using sudo, like this:

sudo ./MyApp

Is it possible to debug my Qt application using root priviliges using QtCreator? How can I do this on an Ubuntu system?

share|improve this question
up vote 1 down vote accepted

I solved it by starting Qt Creator as root.

sudo /usr/bin/qtcreator

Now It will get the root permission to the application when I compile and debug. Now its possible to debug my application with root privilege.

share|improve this answer
That's a very very very stupid thing to do. I am not trying to be offensive. STUPID in the sense that it's not a smart thing to do. And I am sure that most people would NEVER do this. – iharob Sep 10 '15 at 23:39
Don't be a windows user. Don't run everything as root. – Shahbaz Feb 18 at 20:25

Go to Tools-> Options-> Environment

In the "General" Tab under "System" Group there is a "Terminal" option.

The default is "/usr/bin/xterm -e". Replace it with "/usr/bin/xterm -e sudo" or ""/usr/bin/gnome-terminal -x sudo".

Press "Apply" and "OK" Button.

Under mode selector click on "Projects" Select "Run" Option. Under "Run" Group box select "Run in Terminal"

Remember : sudo option must be there

In fedora edit "/etc/sudoers" -: Google "How to edit sudoers"

Next time when you run the program it will be invoked in a new xterm or gnome-terminal with super user permission and will ask for the root password.

share|improve this answer

Running that as root is a horrible idea. Instead, use the source, and make qtcreator use sudo to launch gdb like this. Requires that you run qtcreator from a tty and auth sudo before you launch qtcreator, or configure your user for passwordless sudo (not recommended). I'll code a more complete solution later.

It took me to 1-2 hours code/debug with no prior knowledge of QT. Most that time was spent waiting for the compilation to complete

--- qtcreator-3.0.1.orig/src/plugins/debugger/gdb/gdbprocess.cpp +++ qtcreator-3.0.1/src/plugins/debugger/gdb/gdbprocess.cpp @@ -59,7 +59,11 @@ QByteArray GdbProcess::readAllStandardEr

void GdbProcess::start(const QString &cmd, const QStringList &args) { - m_gdbProc.setCommand(cmd, Utils::QtcProcess::joinArgs(args)); + QStringList sudoArgs; + sudoArgs << cmd << args; + QString sudoCmd = QString::fromUtf8("/usr/bin/sudo"); + + m_gdbProc.setCommand(sudoCmd, Utils::QtcProcess::joinArgs(sudoArgs)); m_gdbProc.start(); }

share|improve this answer

I would run the program from a terminal with a GDB server (as root) and then connect to the server with gdb from QtCreator. You would start gdbserver with something like this:

$ sudo gdbserver host:2345 ./MyApp

Here, you are hosting the server with port 2345. You can also check if your application is indeed running with UID 0.

$ sudo ps -u

Now, in Qt Creator, go Debug -> Start Debugging -> Attach to Running Debug Server. Fill in the form... the most important is the port and server address. I chose and 2345. You can select break at main to break at the beginning of the program. GDB server doesn't start the program until you connect.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.