Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to overcome 'Error 2' during Static Build with minGw (not being able to compile Tokenizer.cpp)
Forum Update on Monday, May 27th 2025

How to overcome 'Error 2' during Static Build with minGw (not being able to compile Tokenizer.cpp)

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 3 Posters 2.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yaoki
    wrote on 8 Aug 2018, 08:41 last edited by koahnig 8 Aug 2018, 09:23
    #1

    I have been struggling to build Static version of Qt so that can deploy the application I have developed. I would sincerely appreciate any tips and pointers (sharing of the experience) to overcome this error. The error message is as follow:

    g++ -c -fno-keep-inline-dllexport -O2 -std=c++1y -fexceptions -mthreads -Wall -W -Wextra -Wno-unknown-pragmas -Wno-comment -Wno-missing-field-initializers -Wno-switch -Wno-unused-parameter -Wno-write-strings -Wno-sign-compare -Wno-missing-braces -Wno-unused-but-set-variable -Wno-unused-variable -Wno-narrowing -Wno-maybe-uninitialized -Wno-strict-aliasing -Wno-type-limits -Wno-unused-local-typedefs -Wno-reorder -Wno-conversion-null -Wno-delete-non-virtual-dtor -Wvla -DUNICODE -D_UNICODE -DWIN32 -DWINVER=0x0601 -D_WIN32_WINNT=0x0601 -D_WINDOWS -D_UNICODE -D_CRT_SECURE_NO_DEPRECATE -D_HAS_EXCEPTIONS=0 -DNOMINMAX -DWIN32_LEAN_AND_MEAN=1 -DANGLE_ENABLE_D3D11 -DANGLE_DEFAULT_D3D11=1 -DNDEBUG -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -D_SECURE_SCL=0 -I. -I../../../../3rdparty/angle/src/compiler/preprocessor -I../../../../../mkspecs/win32-g++  -o .obj/release/Token.o ../../../../3rdparty/angle/src/compiler/preprocessor/Token.cpp
    /C/Qt/5.11.1/Src/qtbase/src/angle/src/compiler/preprocessor/flex_wrapper.sh --noline --nounistd --outfile=release/Tokenizer.cpp ../../../../3rdparty/angle/src/compiler/preprocessor/Tokenizer.l
    process_begin: CreateProcess(NULL, /C/Qt/5.11.1/Src/qtbase/src/angle/src/compiler/preprocessor/flex_wrapper.sh --noline --nounistd --outfile=release/Tokenizer.cpp ../../../../3rdparty/angle/src/compiler/preprocessor/Tokenizer.l, ...) failed.
    make (e=2): The system cannot find the file specified.
    Makefile.Release:162: recipe for target 'release/Tokenizer.cpp' failed
    minGw32-make[7]: *** [release/Tokenizer.cpp] Error 2
    minGw32-make[7]: Leaving directory 'C:/Qt/5.11.1/Src/qtbase/src/angle/src/compiler/preprocessor'
    Makefile:36: recipe for target 'release' failed
    minGw32-make[6]: *** [release] Error 2
    minGw32-make[6]: Leaving directory 'C:/Qt/5.11.1/Src/qtbase/src/angle/src/compiler/preprocessor'
    Makefile:41: recipe for target 'sub-preprocessor-make_first-ordered' failed
    minGw32-make[5]: *** [sub-preprocessor-make_first-ordered] Error 2
    minGw32-make[5]: Leaving directory 'C:/Qt/5.11.1/Src/qtbase/src/angle/src/compiler'
    Makefile:42: recipe for target 'sub-compiler-make_first-ordered' failed
    minGw32-make[4]: *** [sub-compiler-make_first-ordered] Error 2
    minGw32-make[4]: Leaving directory 'C:/Qt/5.11.1/Src/qtbase/src/angle/src'
    Makefile:40: recipe for target 'sub-src-make_first' failed
    minGw32-make[3]: *** [sub-src-make_first] Error 2
    minGw32-make[3]: Leaving directory 'C:/Qt/5.11.1/Src/qtbase/src/angle'
    Makefile:498: recipe for target 'sub-angle-make_first' failed
    minGw32-make[2]: *** [sub-angle-make_first] Error 2
    minGw32-make[2]: Leaving directory 'C:/Qt/5.11.1/Src/qtbase/src'
    Makefile:44: recipe for target 'sub-src-make_first' failed
    minGw32-make[1]: *** [sub-src-make_first] Error 2
    minGw32-make[1]: Leaving directory 'C:/Qt/5.11.1/Src/qtbase'
    makefile:79: recipe for target 'module-qtbase-make_first' failed
    minGw32-make: *** [module-qtbase-make_first] Error 2
    

    The environment is as follows:

    OS Name:                   Microsoft Windows 10 Pro
    OS Version:                10.0.17134 N/A Build 17134
    Processor(s):              1 Processor(s) Installed.
                               [01]: Intel64 Family 6 Model 78 Stepping 3 GenuineIntel ~2607 Mhz
    BIOS Version:              American Megatrends Inc. F.09, 31/05/2016
    Windows Directory:         C:\WINDOWS
    System Directory:          C:\WINDOWS\system32
    Qt version: 5.11.1
    minGw32-make version:
    GNU Make 3.82.90
    Built for i686-w64-mingw32
    

    **This is the contents of the preprocessor folder **

    C:\Qt\5.11.1\Src\qtbase\src\3rdparty\angle\src\compiler\preprocessor>ls
    DiagnosticsBase.cpp       DirectiveParser.cpp  Input.cpp  Macro.cpp          Preprocessor.cpp  Token.h        pp_utils.h
    DiagnosticsBase.h         DirectiveParser.h    Input.h    Macro.h            Preprocessor.h    Tokenizer.h
    DirectiveHandlerBase.cpp  ExpressionParser.h   Lexer.cpp  MacroExpander.cpp  SourceLocation.h  Tokenizer.l
    DirectiveHandlerBase.h    ExpressionParser.y   Lexer.h    MacroExpander.h    Token.cpp         numeric_lex.h
    

    [edit: koahnig] code tags added

    K 1 Reply Last reply 8 Aug 2018, 09:28
    0
    • Y yaoki
      8 Aug 2018, 08:41

      I have been struggling to build Static version of Qt so that can deploy the application I have developed. I would sincerely appreciate any tips and pointers (sharing of the experience) to overcome this error. The error message is as follow:

      g++ -c -fno-keep-inline-dllexport -O2 -std=c++1y -fexceptions -mthreads -Wall -W -Wextra -Wno-unknown-pragmas -Wno-comment -Wno-missing-field-initializers -Wno-switch -Wno-unused-parameter -Wno-write-strings -Wno-sign-compare -Wno-missing-braces -Wno-unused-but-set-variable -Wno-unused-variable -Wno-narrowing -Wno-maybe-uninitialized -Wno-strict-aliasing -Wno-type-limits -Wno-unused-local-typedefs -Wno-reorder -Wno-conversion-null -Wno-delete-non-virtual-dtor -Wvla -DUNICODE -D_UNICODE -DWIN32 -DWINVER=0x0601 -D_WIN32_WINNT=0x0601 -D_WINDOWS -D_UNICODE -D_CRT_SECURE_NO_DEPRECATE -D_HAS_EXCEPTIONS=0 -DNOMINMAX -DWIN32_LEAN_AND_MEAN=1 -DANGLE_ENABLE_D3D11 -DANGLE_DEFAULT_D3D11=1 -DNDEBUG -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -D_SECURE_SCL=0 -I. -I../../../../3rdparty/angle/src/compiler/preprocessor -I../../../../../mkspecs/win32-g++  -o .obj/release/Token.o ../../../../3rdparty/angle/src/compiler/preprocessor/Token.cpp
      /C/Qt/5.11.1/Src/qtbase/src/angle/src/compiler/preprocessor/flex_wrapper.sh --noline --nounistd --outfile=release/Tokenizer.cpp ../../../../3rdparty/angle/src/compiler/preprocessor/Tokenizer.l
      process_begin: CreateProcess(NULL, /C/Qt/5.11.1/Src/qtbase/src/angle/src/compiler/preprocessor/flex_wrapper.sh --noline --nounistd --outfile=release/Tokenizer.cpp ../../../../3rdparty/angle/src/compiler/preprocessor/Tokenizer.l, ...) failed.
      make (e=2): The system cannot find the file specified.
      Makefile.Release:162: recipe for target 'release/Tokenizer.cpp' failed
      minGw32-make[7]: *** [release/Tokenizer.cpp] Error 2
      minGw32-make[7]: Leaving directory 'C:/Qt/5.11.1/Src/qtbase/src/angle/src/compiler/preprocessor'
      Makefile:36: recipe for target 'release' failed
      minGw32-make[6]: *** [release] Error 2
      minGw32-make[6]: Leaving directory 'C:/Qt/5.11.1/Src/qtbase/src/angle/src/compiler/preprocessor'
      Makefile:41: recipe for target 'sub-preprocessor-make_first-ordered' failed
      minGw32-make[5]: *** [sub-preprocessor-make_first-ordered] Error 2
      minGw32-make[5]: Leaving directory 'C:/Qt/5.11.1/Src/qtbase/src/angle/src/compiler'
      Makefile:42: recipe for target 'sub-compiler-make_first-ordered' failed
      minGw32-make[4]: *** [sub-compiler-make_first-ordered] Error 2
      minGw32-make[4]: Leaving directory 'C:/Qt/5.11.1/Src/qtbase/src/angle/src'
      Makefile:40: recipe for target 'sub-src-make_first' failed
      minGw32-make[3]: *** [sub-src-make_first] Error 2
      minGw32-make[3]: Leaving directory 'C:/Qt/5.11.1/Src/qtbase/src/angle'
      Makefile:498: recipe for target 'sub-angle-make_first' failed
      minGw32-make[2]: *** [sub-angle-make_first] Error 2
      minGw32-make[2]: Leaving directory 'C:/Qt/5.11.1/Src/qtbase/src'
      Makefile:44: recipe for target 'sub-src-make_first' failed
      minGw32-make[1]: *** [sub-src-make_first] Error 2
      minGw32-make[1]: Leaving directory 'C:/Qt/5.11.1/Src/qtbase'
      makefile:79: recipe for target 'module-qtbase-make_first' failed
      minGw32-make: *** [module-qtbase-make_first] Error 2
      

      The environment is as follows:

      OS Name:                   Microsoft Windows 10 Pro
      OS Version:                10.0.17134 N/A Build 17134
      Processor(s):              1 Processor(s) Installed.
                                 [01]: Intel64 Family 6 Model 78 Stepping 3 GenuineIntel ~2607 Mhz
      BIOS Version:              American Megatrends Inc. F.09, 31/05/2016
      Windows Directory:         C:\WINDOWS
      System Directory:          C:\WINDOWS\system32
      Qt version: 5.11.1
      minGw32-make version:
      GNU Make 3.82.90
      Built for i686-w64-mingw32
      

      **This is the contents of the preprocessor folder **

      C:\Qt\5.11.1\Src\qtbase\src\3rdparty\angle\src\compiler\preprocessor>ls
      DiagnosticsBase.cpp       DirectiveParser.cpp  Input.cpp  Macro.cpp          Preprocessor.cpp  Token.h        pp_utils.h
      DiagnosticsBase.h         DirectiveParser.h    Input.h    Macro.h            Preprocessor.h    Tokenizer.h
      DirectiveHandlerBase.cpp  ExpressionParser.h   Lexer.cpp  MacroExpander.cpp  SourceLocation.h  Tokenizer.l
      DirectiveHandlerBase.h    ExpressionParser.y   Lexer.h    MacroExpander.h    Token.cpp         numeric_lex.h
      

      [edit: koahnig] code tags added

      K Offline
      K Offline
      koahnig
      wrote on 8 Aug 2018, 09:28 last edited by
      #2

      @yaoki

      Hi and welcome to devnet forum

      Please use code tags in your postings. They provide also some helpful formatting for different other output.

      The error message stems from your makefile. AFAIK that is odd.

      From where did you get the source for compilation?

      In general you can also easily deploy applciations based on dlls to other machines.
      You should be aware of the license implications in case you like to distribute your work.

      Vote the answer(s) that helped you to solve your issue(s)

      Y 1 Reply Last reply 8 Aug 2018, 09:42
      1
      • K koahnig
        8 Aug 2018, 09:28

        @yaoki

        Hi and welcome to devnet forum

        Please use code tags in your postings. They provide also some helpful formatting for different other output.

        The error message stems from your makefile. AFAIK that is odd.

        From where did you get the source for compilation?

        In general you can also easily deploy applciations based on dlls to other machines.
        You should be aware of the license implications in case you like to distribute your work.

        Y Offline
        Y Offline
        yaoki
        wrote on 8 Aug 2018, 09:42 last edited by yaoki 8 Aug 2018, 09:47
        #3

        @koahnig
        Thank you very much for your reply and very useful advices.

        The source was obtained using qt-unified-windows-x86-3.0.5-online.exe that I have downloaded from Qt's official website.

        I have also tried windeployqt.exe and get all dll files and deploy that way; however, I got an error message when I tried to open the app in the other computer 'The code execution cannot proceed because libgcc_s_dw2-1.dll was not found. Reinstalling the program may fix this problem'.

        Again I sincerely appreciate anybody's input on this.

        M K 2 Replies Last reply 8 Aug 2018, 12:33
        0
        • Y yaoki
          8 Aug 2018, 09:42

          @koahnig
          Thank you very much for your reply and very useful advices.

          The source was obtained using qt-unified-windows-x86-3.0.5-online.exe that I have downloaded from Qt's official website.

          I have also tried windeployqt.exe and get all dll files and deploy that way; however, I got an error message when I tried to open the app in the other computer 'The code execution cannot proceed because libgcc_s_dw2-1.dll was not found. Reinstalling the program may fix this problem'.

          Again I sincerely appreciate anybody's input on this.

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 8 Aug 2018, 12:33 last edited by
          #4

          @yaoki

          Hi
          That is mingw runtime. You might need to add
          win32 {
          QMAKE_LFLAGS += -static-libgc
          }
          to the pro file to link that static as well.

          Y 1 Reply Last reply 8 Aug 2018, 20:11
          1
          • Y yaoki
            8 Aug 2018, 09:42

            @koahnig
            Thank you very much for your reply and very useful advices.

            The source was obtained using qt-unified-windows-x86-3.0.5-online.exe that I have downloaded from Qt's official website.

            I have also tried windeployqt.exe and get all dll files and deploy that way; however, I got an error message when I tried to open the app in the other computer 'The code execution cannot proceed because libgcc_s_dw2-1.dll was not found. Reinstalling the program may fix this problem'.

            Again I sincerely appreciate anybody's input on this.

            K Offline
            K Offline
            koahnig
            wrote on 8 Aug 2018, 13:08 last edited by
            #5

            @yaoki said in How to overcome 'Error 2' during Static Build with minGw (not being able to compile Tokenizer.cpp):

            @koahnig
            Thank you very much for your reply and very useful advices.

            The source was obtained using qt-unified-windows-x86-3.0.5-online.exe that I have downloaded from Qt's official website.

            I have also tried windeployqt.exe and get all dll files and deploy that way; however, I got an error message when I tried to open the app in the other computer 'The code execution cannot proceed because libgcc_s_dw2-1.dll was not found. Reinstalling the program may fix this problem'.

            Again I sincerely appreciate anybody's input on this.

            You are using the source code accompanying a pre-built?

            AFAIK this is still not recommended. You can find the source code all versions in Qt archives. Here is a link to the complete source for Qt5.11.1. For windows you need to download always the zip. The tar.xz is for linux based systems.

            Vote the answer(s) that helped you to solve your issue(s)

            Y 1 Reply Last reply 9 Aug 2018, 05:00
            2
            • Y Offline
              Y Offline
              yaoki
              wrote on 8 Aug 2018, 14:05 last edited by
              #6

              @mrjj and @koahnig

              thank you very much for your inputs. I will try them both and update with you of the outcome.

              1 Reply Last reply
              0
              • M mrjj
                8 Aug 2018, 12:33

                @yaoki

                Hi
                That is mingw runtime. You might need to add
                win32 {
                QMAKE_LFLAGS += -static-libgc
                }
                to the pro file to link that static as well.

                Y Offline
                Y Offline
                yaoki
                wrote on 8 Aug 2018, 20:11 last edited by
                #7

                @mrjj

                Again thank you for the pointer, it turned out that the PATH was pointing to the different MinGW than the one I was using to compile my Qt app. So now the dynamically linked one can be deployed!! Thank you so much!! (currently trying to make static build following koahnig's suggestion)

                M 1 Reply Last reply 8 Aug 2018, 20:13
                1
                • Y yaoki
                  8 Aug 2018, 20:11

                  @mrjj

                  Again thank you for the pointer, it turned out that the PATH was pointing to the different MinGW than the one I was using to compile my Qt app. So now the dynamically linked one can be deployed!! Thank you so much!! (currently trying to make static build following koahnig's suggestion)

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 8 Aug 2018, 20:13 last edited by
                  #8

                  @yaoki
                  Good luck.

                  1 Reply Last reply
                  0
                  • K koahnig
                    8 Aug 2018, 13:08

                    @yaoki said in How to overcome 'Error 2' during Static Build with minGw (not being able to compile Tokenizer.cpp):

                    @koahnig
                    Thank you very much for your reply and very useful advices.

                    The source was obtained using qt-unified-windows-x86-3.0.5-online.exe that I have downloaded from Qt's official website.

                    I have also tried windeployqt.exe and get all dll files and deploy that way; however, I got an error message when I tried to open the app in the other computer 'The code execution cannot proceed because libgcc_s_dw2-1.dll was not found. Reinstalling the program may fix this problem'.

                    Again I sincerely appreciate anybody's input on this.

                    You are using the source code accompanying a pre-built?

                    AFAIK this is still not recommended. You can find the source code all versions in Qt archives. Here is a link to the complete source for Qt5.11.1. For windows you need to download always the zip. The tar.xz is for linux based systems.

                    Y Offline
                    Y Offline
                    yaoki
                    wrote on 9 Aug 2018, 05:00 last edited by
                    #9

                    @koahnig
                    Thank you for the input. In addition to downloading the source from the archive (https://download.qt.io/archive/qt/5.11/5.11.1/single/) I had to add C:\Qt\qt-everywhere-src-5.11.1\gnuwin32\bin to the path then I was successfully able to run mingw32-make!!

                    Again thank you very much for your useful help!

                    K 1 Reply Last reply 9 Aug 2018, 08:14
                    1
                    • Y yaoki
                      9 Aug 2018, 05:00

                      @koahnig
                      Thank you for the input. In addition to downloading the source from the archive (https://download.qt.io/archive/qt/5.11/5.11.1/single/) I had to add C:\Qt\qt-everywhere-src-5.11.1\gnuwin32\bin to the path then I was successfully able to run mingw32-make!!

                      Again thank you very much for your useful help!

                      K Offline
                      K Offline
                      koahnig
                      wrote on 9 Aug 2018, 08:14 last edited by koahnig 8 Sept 2018, 18:58
                      #10

                      @yaoki

                      Not sure why you needed to have the directory added to the PATH environment.

                      Beware that you might have added a trap for the future, when changing to a different Qt version. I remember that PATH played a role when I was still using MSVC long ago. Since I am using Qt creator and MinGW, the setting is no longer required, respectively it is handled by creator. There you can change to a different toolkit very fast without remembering all the odd, forgotten stuff.

                      Vote the answer(s) that helped you to solve your issue(s)

                      1 Reply Last reply
                      2

                      1/10

                      8 Aug 2018, 08:41

                      • Login

                      • Login or register to search.
                      1 out of 10
                      • First post
                        1/10
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved