[Solved]Qt4.8.1 for Desktop (MinGW) Compiler Error (-Wl,-subsystem,windows)



  • Good day

    I have the following program:
    @/* temp.cpp Qt test file */
    #include <iostream>

    int main()
    {
    using namespace std;
    cout << "Hello world";
    return 0;
    }@

    I open Qt4.8.1 for Desktop (MinGW) and ran the following(also showing the output):
    @
    d:\temp>qmake -project

    d:\temp>qmake

    d:\temp>mingw32-make
    mingw32-make -f Makefile.Debug
    mingw32-make[1]: Entering directory `d:/temp'
    g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\QtSDK\Desktop\Qt\4.8.1\mingw\include\QtCore" -I"..\QtSDK\Desktop\Qt\4.8.1\mingw\include\QtGui" -I"..\QtSDK\Desktop\Qt\4.8.1\mingw\include" -I"." -I"..\QtSDK\Desktop\Qt\4.8.1\mingw\include\ActiveQt" -I"debug" -"..\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\default" -o debug\temp.o temp.cpp

    g++ -mthreads -Wl,-subsystem,windows -o debug\temp.exe debug/temp.o -L"d:\QtSDK\Desktop\Qt\4.8.1\mingw\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4

    mingw32-make[1]: Leaving directory `d:/temp'

    d:\temp>debug\temp

    d:\temp>g++ -o debug\temp.exe temp.cpp

    d:\temp>debug\temp
    Hello world
    d:\temp>
    @
    So I compiled the same project with qmake Makefile and directly with mingw. As you can see the qmake compilation compiled a file doing nothing where the mingw compiled correctly. Any ideas why or what is going on? The SDK is working correctly so the installed Qt is not broken.

    Any help please?



  • I have found the problem, by removing the flags

    @-Wl,-subsystem,windows@

    I can compile a working exe. What does these flags mean, I cant find them in the documentation? Why are they added to the qmake generated Makefiles?



  • -Wl,-subsystem,windows makes an application with GUI and -Wl,-subsystem,console makes a console application - and those were added because you created an Qt GUI application instead a Qt console application //add CONFIG += console to your .pro file (when you create a console application) and then run qmake and it should build just fine.



  • Great thanks, it works now. Using
    @qmake -project CONFIG+=console@

    Followed with all the rest of the commands.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.