Results 1 to 9 of 9

Thread: No output when compiling in Qt, but works with g++

  1. #1
    Join Date
    May 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default No output when compiling in Qt, but works with g++

    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:

    Qt Code:
    1. g++ -I../../inc -DGTEST_LINKED_AS_SHARED_LIBRARY=1 -g -Wall -Wextra -c main.cpp
    2. g++ -o tests main.o -LC:\gtest-1.5.0\gtest-1.5.0\make -lgtest_dll
    To copy to clipboard, switch view to plain text mode 

    Here is my Qt pro file:
    Qt Code:
    1. DEFINES += GTEST_LINKED_AS_SHARED_LIBRARY=1
    2. SOURCES += main.cpp
    3. INCLUDEPATH += ../../inc
    4. LIBS += -LC:\gtest-1.5.0\gtest-1.5.0\make -lgtest_dll
    To copy to clipboard, switch view to plain text mode 

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

    Qt Code:
    1. #include <gtest/gtest.h>
    2.  
    3. int main(int argc, char **argv)
    4. {
    5. testing::InitGoogleTest(&argc, argv);
    6. return RUN_ALL_TESTS();
    7. }
    8.  
    9. TEST(SomeTest, SomeTestTest)
    10. {
    11. ASSERT_EQ(1,1);
    12. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: No output when compiling in Qt, but works with g++

    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).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: No output when compiling in Qt, but works with g++

    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

  4. #4
    Join Date
    May 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: No output when compiling in Qt, but works with g++

    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.

  5. #5
    Join Date
    May 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: No output when compiling in Qt, but works with g++

    OK, I'll give that a try. Does that mean that without that directive, Qt suppresses output completely? (Qt Creator IDE, console, etc.)

  6. #6
    Join Date
    Feb 2008
    Posts
    98
    Thanks
    2
    Thanked 24 Times in 24 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: No output when compiling in Qt, but works with g++

    Why are you using the Google Test framework? Do you know about QtTest?

  7. #7
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: No output when compiling in Qt, but works with g++

    Quote Originally Posted by dmateer View Post
    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.

  8. #8
    Join Date
    May 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: No output when compiling in Qt, but works with g++

    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.

  9. #9
    Join Date
    Apr 2016
    Posts
    1
    Qt products
    Qt5
    Platforms
    MacOS X Windows Android

    Default Re: No output when compiling in Qt, but works with g++

    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

Similar Threads

  1. QLabel setPixmap only works twice?
    By December in forum Qt Programming
    Replies: 0
    Last Post: 28th February 2010, 11:59
  2. How works tile() ?
    By looki in forum Qt Programming
    Replies: 0
    Last Post: 30th September 2008, 14:25
  3. DeleteLater works... but why?
    By TheGrimace in forum Qt Programming
    Replies: 11
    Last Post: 6th June 2007, 16:14
  4. How simpletreeview example works?
    By igorko in forum Qt Programming
    Replies: 1
    Last Post: 19th June 2006, 10:59

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.