Error in building -every- project with the Qt Creator

  • Hi!

    I've installed the latest and greatest Qt SDK (version 1.1.2, using the offline installer) on my Windows 7 x86 machine.
    I have installed ALL of the components (including the optional ones).
    The installation seemed to be successful and I opened Qt Creator to start creating Qt projects.

    I've selected the "Qt GUI Application" project template. I haven't added any code, and clicked the "run" button.

    The compiler reported 98 errors and 87 warnings, ALL of them regarding something not defined in some headers (sorry I can't provide a more specific detailing of the error).

    I don't think it should happen - the project is a template, and was run without code added, therefore should run perfectly, right...?

    The bottom line is: The simplest project from a template (or any project, for that matter) does not compile and yields 98 errors and 87 warnings every time.

    Can someone help me troubleshoot this problem? Google wasn't very helpful this time...

  • Try running Qt Creator as administrator.

  • xcoder - Thanks, but no luck.
    Still getting 98 errors and 87 warnings.

    Here they are:
    Running build steps for project untitled...
    Starting: "c:\qtsdk\desktop\qt\4.7.3\mingw\bin\qmake.exe" C:\Users\Ronen\untitled\ -r -spec win32-g++
    The process "c:\qtsdk\desktop\qt\4.7.3\mingw\bin\qmake.exe" exited normally.
    Starting: "C:\QtSDK\mingw\bin\mingw32-make.exe"
    C:/QtSDK/mingw/bin/mingw32-make -f Makefile.Debug
    mingw32-make[1]: Entering directory `C:/Users/Ronen/untitled-build-desktop'
    c:\QtSDK\Desktop\Qt\4.7.3\mingw\bin\uic.exe ..\untitled\mainwindow.ui -o ui_mainwindow.h
    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.7.3\mingw\include\QtCore" -I"......\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui" -I"......\QtSDK\Desktop\Qt\4.7.3\mingw\include" -I"......\QtSDK\Desktop\Qt\4.7.3\mingw\include\ActiveQt" -I"debug" -I"." -I"..\untitled" -I"." -I"......\QtSDK\Desktop\Qt\4.7.3\mingw\mkspecs\win32-g++" -o debug\main.o ..\untitled\main.cpp
    In file included from c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/bits/postypes.h:42,
    from c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/bits/char_traits.h:42,
    from c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/string:42,
    from ......\QtSDK\Desktop\Qt\4.7.3\mingw\include/QtCore/qstring.h:60,
    from ......\QtSDK\Desktop\Qt\4.7.3\mingw\include/QtCore/qobject.h:48,
    from ......\QtSDK\Desktop\Qt\4.7.3\mingw\include/QtCore/qcoreapplication.h:45,
    from ......\QtSDK\Desktop\Qt\4.7.3\mingw\include/QtGui/qapplication.h:45,
    from ......\QtSDK\Desktop\Qt\4.7.3\mingw\include/QtGui/QApplication:1,
    from ..\untitled\main.cpp:1:
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:67: error: '::mbstate_t' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:141: error: '::wint_t' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:143: error: '::btowc' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:144: error: '::fgetwc' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:145: error: '::fgetws' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:146: error: '::fputwc' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:147: error: '::fputws' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:148: error: '::fwide' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:149: error: '::fwprintf' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:150: error: '::fwscanf' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:151: error: '::getwc' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:152: error: '::getwchar' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:153: error: '::mbrlen' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:154: error: '::mbrtowc' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:155: error: '::mbsinit' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:156: error: '::mbsrtowcs' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:157: error: '::putwc' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:158: error: '::putwchar' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:159: error: '::swprintf' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:160: error: '::swscanf' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:161: error: '::ungetwc' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:162: error: '::vfwprintf' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:164: error: '::vfwscanf' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:166: error: '::vswprintf' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:168: error: '::vswscanf' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:170: error: '::vwprintf' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:172: error: '::vwscanf' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:174: error: '::wcrtomb' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:180: error: '::wcsftime' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:185: error: '::wcsrtombs' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:187: error: '::wcstod' has not been declared
    c:\qtsdk\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:189: error: '::wcstof' has not been declared

    It's only a little... There are more. A LOT MORE.

  • Any help now?
    I have no intention learning the stupid MFC crap...
    I wanted to learn Qt which is far more superior but I don't know... If I won't be able to compile anything, there is no use.

    All of the other errors are alike; it complains about something not being declared...

    So, can anyone help me...?

  • Looks like your toolchain is broken.
    First step would be to reinstall the Qt SDK.

  • Lukas, I have already re-installed Qt two times, and nothing helped.
    Maybe only a single component is broken, rather then Qt itself?

    Like I said before, I have already re-installed Qt a couple of times. Every time I have selected all of the components that the installation offered me, including MINGW 4.4. Could MINGW be the cause of the problem?

  • I think so.

    Can you build a simple application at command line?

  • I'm having trouble compiling from the command line...

    1. Opened up the "Qt 4.7.3 for Desktop (MinGW)
    2. Wrote a small C++ file:

    #include <QApplication>
    #include <QLabel>

    int main(int argc, char **argv) {
    QApplication app(argc, argv);
    QLabel *qlbl = new QLabel("Testing");

    return app.exec();

    1. Followed along these instructions:

    But the command prompt does not recognize the make command.

    Am I doing something wrong..?

  • Did you use mingw-make? Or just make?

  • Tried both, actually...

    Well, maybe MinGW screws everything up...
    What if I'll download the latest version of MinGW from their website, and somehow get Qt Creator to use that version?

    Is that even possible?

  • Yes, Qt Creator can use custom mingw installations: Go to Tools->Options->Tool chains and add a new Mingw tool chain. There is documentation on how to do that exactly available in the Qt Creator manual. It is really informative, I can highly recommend spending some time skimming over it:-)

  • Tobias - I have added the MinGW that I've installed using the "official" MinGW installer. I have specified the path to the compiler, and the debugger path was automatically added by Qt.

    Something is odd - I've told Qt to install it's own MinGW (located inside the QtSDK folder), yet Qt uses my MinGW that was INSTALLED EARLIER using the MinGW installer. Maybe THAT is causing the problem!

    So, I try to remove the automatically detected MinGW, but I can't - the "Remove" button remains disabled.

    So, how should I tell Qt to use the MinGW that was installed with it?

  • Any help..?

  • Is it possible that there are remainings of your old MinGW installation left in the environment variables (especially PATH) or the registry?

  • Lukas - I have remove the Old MinGW from the PATH and physically from the Hard-Drive.
    I've re-installed Qt and verified that Qt is using the MinGW inside the Qt directory (which it does).

    However, it appears to be worse - now when I run a Qt example in the Qt Creator startup screen, the compilation yields 100 errors and 97 warnings... The same errors it gave me when it was using the old MinGW (see a couple of posts above).

    What's going on here..?

  • Try adding -U__STRICT_ANSI__ to your compiler flags.

  • Lukas, sorry for the stupidity, but how exactly do I do that? I'm compiling from the IDE and I haven't seen such option in the Options dialog. Can you please tell me how to do that?

  • Try installing Qt on other windows 7, and check if it works, because it worked fine for me. And I'm using windows 7 professional x86.

    There might be some kind of problems with your system.

    You know windows reinstall is the mighty solution for everything :D

  • xcoder - I don't have another Windows 7 machine, and I can't (and won't, for that matter) re-install my current operating system.

    Trust me, I know that re-installing Windows is like a magic troubleshooting solution. However, I'm not going to get into the mess of re-installing Windows and all the programs I have (and backup all of my digital music library) just to get a piece of software to work. A software that is, as far as I can tell, doesn't work because a peculiar reason.

    Sorry, but that solution is irrelevant. As much as I would like to stay away from any Microsoft crap like MFC or WinAPI, I can't waste time trying to figure out why am I getting a hundred errors for no reason.

    I would appreciate any other solutions, if there are any.

  • I still bet that your MinGW installation is broken due to a corrupted environment.

    Open a command promt, unset all environment variables (especially PATH, INCLUDE, LIB, QTDIR, QMAKESPEC) and then execute qtvars2.bat from the Qt SDK directory to get a fresh Qt environment.

    As for STRICT_ANSI just add @ #undef STRICT_ANSI @ at the top of your source file (normally this is not needed and if it works afterwards it is most likely that something is still broken).

  • Lukas - I don't have the qtvars2.bat file in my Qt SDK directory. I only have qtenv.

  • [quote author="ElectroRonen" date="1311686387"]Lukas - I don't have the qtvars2.bat file in my Qt SDK directory. I only have qtenv.[/quote]

    Should do the same.

Log in to reply