PDA

View Full Version : Qt Creator Plain C++ Project won't run/debug...



jiapei100
22nd July 2012, 04:29
Hi, all:

Environment:
OS: Ubuntu 12.04
Qt: Qt Creator 2.4.1
Based on Qt 4.8.0 (32 bit)

Built on Mar 21 2012 at 23:05:03


As titled:
After having created a plain C++ project, with a default Hello World in main.cpp

#include <iostream>

using namespace std;

int main()
{
cout << "Hello World!" << endl;
return 0;
}



It's so strange that I'm not able to debug/run this application after building.
The .pro file is as simple as:

TEMPLATE = app
CONFIG += console
CONFIG -= qt

SOURCES += main.cpp


Whenever I tried to run it from within Qt Creator IDE, a Terminal jumped out and the program hangs on the screen and the program is not able to run at all. Did anybody else meet the same problem?

cheers
Pei

ChrisW67
22nd July 2012, 04:33
Which terminal program are you using. Konsole, for example, causes issue for me but the default "xterm -e" works fine.

You will not be able to adequately debug this program unless you build it in debug mode by using "qmake CONFIG+=debug" manually or form an IDE that does the equivalent for you.

amleto
22nd July 2012, 12:28
for *&^%s sake another crossposter
http://www.qtforum.org/article/38257/qt-creator-plain-c-project-won-t-run-debug.html#post119889

wysota
22nd July 2012, 16:40
for *&^%s sake another crossposter
http://www.qtforum.org/article/38257/qt-creator-plain-c-project-won-t-run-debug.html#post119889

Just stop posting there like we did 6 years ago and you won't be annoyed anymore :)

amleto
22nd July 2012, 19:25
I think you are right.

jiapei100
23rd July 2012, 23:21
Hi, Thank you for your help Chris.


Which terminal program are you using. Konsole, for example, causes issue for me but the default "xterm -e" works fine.
When I run my application, "GNOME Terminal 3.4.1.1" jumped out automatically.



You will not be able to adequately debug this program unless you build it in debug mode by using "qmake CONFIG+=debug" manually or form an IDE that does the equivalent for you.
1) Yes, I'm running it, instead of debugging it.
2) Even debugging it with CONFIG += debug, namely

TEMPLATE = app
CONFIG += console debug
CONFIG -= qt

SOURCES += main.cpp
the terminal still hangs....

Added after 45 minutes:

Hi, amleto:

Thanks for your reply. But, unfortunately, here on my computer, it doesn't work.

Environment:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04 LTS
Release: 12.04
Codename: precise

$ uname -a
Linux XXXXXXXXX 3.2.0-27-generic-pae #43-Ubuntu SMP Fri Jul 6 15:06:05 UTC 2012 i686 athlon i386 GNU/Linux



.pro file

TARGET = noqt
CONFIG += console
CONFIG -= app_bundle

CONFIG -= qt

TEMPLATE = app

SOURCES += main.cpp


main.cpp file

#include <iostream>

using namespace std;

int main()
{
cout << "Hello World!" << endl;
return 0;
}




I'm guessing it might have something to do with the OS, namely, current Ubuntu.


Thanks anyway.


Best Regards
Pei



for *&^%s sake another crossposter
http://www.qtforum.org/article/38257/qt-creator-plain-c-project-won-t-run-debug.html#post119889

jiapei100
24th July 2012, 09:29
It seems it has something to do with (QtCreator under Ubuntu 12.04) only.
Because after the compilation and building, if I entered subfolder containing the executive, just from the bash (both Debug and Release), I'm able to have Hello World printed out. However, it seems it's just the problem from QtCreator IDE.
And the outcome I obtained is:

Starting ...../test_plaincpp-build-desktop-Qt_4_8_1_in_PATH__System__Debug/noqt...
......plaincpp-build-desktop-Qt_4_8_1_in_PATH__System__Debug/noqt exited with code 0


Please, give me a hand....

Best Regards
Pei

wysota
24th July 2012, 11:16
Could you please check the terminal settings in Qt Creator and change it to xterm -e or just uncheck "run in terminal" in your project settings?

jiapei100
24th July 2012, 15:59
Wow, Hi, Thanks wysota:

After I uncheck "run in terminal", it seems now it's able to work !! But there is still some extra output:

Debugging starts
&"warning: GDB: Failed to set controlling terminal: Invalid argument\n"


If I change Qt Creator -> Tools -> Options-> Environment -> Systems -> Terminal to "xterm -e". It's fine when running the program, but when I tried to debug it, I got an error dialog:

Failed to start application
ptrace: Operation not permitted.


Anyway, uncheck "run in terminal" seems to be a better solution.

Cheers
Pei


[/QUOTE]

Could you please check the terminal settings in Qt Creator and change it to xterm -e or just uncheck "run in terminal" in your project settings?

checkthamethod
26th July 2012, 18:09
Where is project options located?