Important: Please read the Qt Code of Conduct -

Qt5 MinGW build error: '_fileno' was not declared

  • Hi!

    I'm trying to build Qt5 shared, as I can't stand those enormous icuu libraries.
    But I'm having problem building it.

    This is an error that I get:
    @main.cpp: In member function 'virtual QVariant PatternistApplicationParser::defaultValue(const QApplicationArgument&) const':
    main.cpp:196:36: error: '_fileno' was not declared in this scope
    mingw32-make[4]: *** [.obj/release_shared/main.o] Error 1
    mingw32-make[4]: Leaving directory 'C:/Dev/Qt5/Qt5_MinGW_Shared/qtxmlpatterns/tools/xmlpatterns'@

    Happens with static and shared build on Windows 7 and Windows 8, both 64-bit.
    I'm using MinGW 4.7.2 32-bit.
    I followed the tutorial "here": building Qt5 from git, and added -no-webkit flag and -opengl desktop.

    Search didn't throw me any useful results.


  • Hi!

    Are they someone to help? I have exactly the same problem.

    I noticed that the compiler uses the strict ansi norm, so the _fileno function is not defined. Commenting
    @#ifndef STRICT_ANSI@

    and the matching #endif in the stdio.h file is working but very tricky.

    Before updating the sources, I never had any problem to compile Qt.

    Best regards

  • Hi all!
    Had the same problem.
    Does everybody must have to patch stdio.h?

  • Hi!

    I didn't patch it.
    I downloaded source code from "here": and build this one instead. It builds without any problems.

  • Current git version abort compilation with this error message.

  • I have the same problem with the current Qt 5.1 Beta in Windows 7 32-bit using MinGW 4.7

    Anybody who solved this problem?

    Additional Info: Error is found within <Qt5_directory>/qtxmlpatterns/tools/xmlpatterns/main.cpp

    @//from main.cpp
    #ifdef Q_OS_WIN
    /* If we don't open stdout in "binary" mode on Windows, it will translate
    * 0xA into 0xD 0xA. */
    _setmode(_fileno(stdout), _O_BINARY);
    m_stdout = _wfdopen(_fileno(stdout), L"wb");
    out->open(m_stdout, QIODevice::WriteOnly);
    out->open(stdout, QIODevice::WriteOnly);

  • Same here. I also get alot warnings about not found generated files within webkit module compilation...

  • Iam facing the same error. Building Qt 5.1.1, on windows 8 (32 bit), using mingw32-make .

    URGENT help needed !!

  • This is not a fix but a workaround. I'm not sure if this is a MinGW or Qt issue.
    Anyway here we go: modify qt-everywhere-opensource-src-5.1.1/qtxmlpatterns/tools/xmlpatterns/main.cpp
    and add before #include "main.h"

    #include <stdio.h>
    extern "C" {
    _CRTIMP int __cdecl __MINGW_NOTHROW _fileno (FILE*);

  • adding following one line in xmlpatterns\main.cpp before #include "main.h" apparently solve the problem..

    #define _fileno(F) ((F)->_file)

    hope everybody got same result...

Log in to reply