PDA

View Full Version : No output when compiling in Qt, but works with g++



dmateer
7th May 2010, 22:04
I have a simple Qt project that is using the Google Test framework. When I compile and run my main.cpp using g++, everything works. However, when I compile and run using Qt, there is no output. There are no errors; the program immediately exits with code 0. It almost seems like my output is just getting lost. I get the same (non)output whether running from Qt Creator or starting the application from a command line.

Here is what works:


g++ -I../../inc -DGTEST_LINKED_AS_SHARED_LIBRARY=1 -g -Wall -Wextra -c main.cpp
g++ -o tests main.o -LC:\gtest-1.5.0\gtest-1.5.0\make -lgtest_dll

Here is my Qt pro file:

DEFINES += GTEST_LINKED_AS_SHARED_LIBRARY=1
SOURCES += main.cpp
INCLUDEPATH += ../../inc
LIBS += -LC:\gtest-1.5.0\gtest-1.5.0\make -lgtest_dll

My main.cpp follows, although I know that it is fine because when I compile outside of Qt, it is working:


#include <gtest/gtest.h>

int main(int argc, char **argv)
{
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

TEST(SomeTest, SomeTestTest)
{
ASSERT_EQ(1,1);
}

wysota
8th May 2010, 10:09
What do you mean "compiling using Qt"? Qt is not a compiler. Qt projects are compiled using g++ (or other toolchains, depending on the platform).

Zlatomir
8th May 2010, 16:11
I'm not sure if i understand your problem, but if you create console application and you want console output you must add this line in your project file: CONFIG += console

dmateer
12th May 2010, 17:23
I'm compiling within Qt Creator, which is using g++ at the end of the day. But it's also including whatever "Qt stuff" it needs, which is why (I'm assuming) the testing framework is working with plain-vanilla g++ but not g++ with Qt.

dmateer
12th May 2010, 17:24
OK, I'll give that a try. Does that mean that without that directive, Qt suppresses output completely? (Qt Creator IDE, console, etc.)

victor.fernandez
12th May 2010, 17:27
Why are you using the Google Test framework? Do you know about QtTest?

Zlatomir
12th May 2010, 18:40
OK, I'll give that a try. Does that mean that without that directive, Qt suppresses output completely? (Qt Creator IDE, console, etc.)

Ot doesn't "suppresses" output, but QT Creator, just like any IDE doesn't expect any output to console, if you didn't specifically create a Console application (VS has something like <SubSystem>Console</SubSystem> in project files and other IDE's must have some switches too).

My recommendation is ONLY if you use console application with console output.

dmateer
10th June 2010, 14:50
As far as QtTest: yes, we will probably use that as well for "driving" the application--that's a nice feature! But--at least right now--Google Test is much more feature-rich, and we are using some of those goodies. Its out-of-the-box interoperability with the Google Mock framework is a nice feature as well.

harilnt
23rd April 2016, 07:04
Hi
i am new in Qt and can anybody provide the GTEST framework for Qt android NDK
we are planning to run GTEST for GUI application code