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. Qt5 C++ application compilation from prompt
Forum Updated to NodeBB v4.3 + New Features

Qt5 C++ application compilation from prompt

Scheduled Pinned Locked Moved Unsolved General and Desktop
27 Posts 6 Posters 4.3k Views 2 Watching
  • 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.
  • 8Observer88 Offline
    8Observer88 Offline
    8Observer8
    wrote on last edited by 8Observer8
    #17

    I don't know. I just post my result:

    E:_Projects\Qt\test>mingw32-make
    C:/Qt6/Tools/mingw810_64/bin/mingw32-make -f Makefile.Release
    mingw32-make[1]: Entering directory 'E:/_Projects/Qt/test'
    g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++1z -Wall -Wextra -Wextra -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I. -IC:/Qt6/6.2.0/mingw81_64/include -IC:/Qt6/6.2.0/mingw81_64/include/QtGui -IC:/Qt6/6.2.0/mingw81_64/include/QtCore -Irelease -I/include -IC:/Qt6/6.2.0/mingw81_64/mkspecs/win32-g++ -o release\main.o main.cpp
    g++ -Wl,-s -Wl,-subsystem,windows -mthreads -o release\app.exe release/main.o C:\Qt6\6.2.0\mingw81_64\lib\libQt6Gui.a C:\Qt6\6.2.0\mingw81_64\lib\libQt6Core.a -lmingw32 C:\Qt6\6.2.0\mingw81_64\lib\libQt6EntryPoint.a -lshell32
    mingw32-make[1]: Leaving directory 'E:/_Projects/Qt/test'

    1 Reply Last reply
    0
    • 8Observer88 8Observer8

      Try to use these commands:

      qmake -makefile
      mingw32-make
      "./release/app"

      .pro

      QT += core gui widgets
      
      CONFIG += c++11
      
      SOURCES += \
          main.cpp
      
      TARGET = app
      

      It works with Qt6. Perhaps this will work with Qt5.

      Edited 1/12/2023. Added widgets.

      R Offline
      R Offline
      Robert M.
      wrote on last edited by
      #18

      @8Observer8 said in Qt5 C++ application compilation from prompt:

      mingw32-make

      It does not work with Qt5 on my computer.
      In file included from main.cpp:1:
      mainwindow.h:4:10: fatal error: QMainWindow: No such file or directory
      #include <QMainWindow>
      ^~~~~~~~~~~~~
      compilation terminated.
      mingw32-make[1]: *** [Makefile.Release:200: release/main.o] Error 1
      mingw32-make[1]: Leaving directory 'C:/Users/lenovo/Projekty/dirtyphp_qt'
      mingw32-make: *** [Makefile:38: release] Error 2

      jsulmJ 1 Reply Last reply
      0
      • R Robert M.

        @8Observer8 said in Qt5 C++ application compilation from prompt:

        mingw32-make

        It does not work with Qt5 on my computer.
        In file included from main.cpp:1:
        mainwindow.h:4:10: fatal error: QMainWindow: No such file or directory
        #include <QMainWindow>
        ^~~~~~~~~~~~~
        compilation terminated.
        mingw32-make[1]: *** [Makefile.Release:200: release/main.o] Error 1
        mingw32-make[1]: Leaving directory 'C:/Users/lenovo/Projekty/dirtyphp_qt'
        mingw32-make: *** [Makefile:38: release] Error 2

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #19

        @Robert-M said in Qt5 C++ application compilation from prompt:

        mainwindow.h:4:10: fatal error: QMainWindow: No such file or directory

        Add

        QT += widgets
        

        to your pro file as shown in documentation.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1
        • R Robert M.

          C:\Users\lenovo>g++ --version
          g++ (i686-posix-dwarf-rev0, Built by MinGW-W64 project) 8.1.0
          Copyright (C) 2018 Free Software Foundation, Inc.
          This is free software; see the source for copying conditions. There is NO
          warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
          C:\Users\lenovo>make --version
          GNU Make 3.81
          Copyright (C) 2006 Free Software Foundation, Inc.
          Ten program jest darmowy; warunki kopiowania są opisane w źródłach.
          Autorzy nie dają ŻADNYCH gwarancji, w tym nawet gwarancji SPRZEDAWALNOŚCI
          lub PRZYDATNOŚCI DO KONKRETNYCH CELÓW.
          Ten program został zbudowany dla i386-pc-mingw32

          In Qt Creator I see:

          C:\Qt\Tools\mingw730_32\bin\g++.exe
          C:\Qt\Tools\mingw730_64\bin\g++.exe
          C:\Qt\Tools\mingw900_64\bin\g++.exe

          In make file I see:

          ####### Compiler, tools and options

          CC = gcc
          CXX = g++
          DEFINES = -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_DEPRECATED_WARNINGS -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN
          CFLAGS = -fno-keep-inline-dllexport -g -Wall -W -Wextra $(DEFINES)
          CXXFLAGS = -fno-keep-inline-dllexport -g -Wall -W -Wextra -fexceptions -mthreads $(DEFINES)
          INCPATH = -I. -I........\Qt\5.13.2\mingw73_64\include -I........\Qt\5.13.2\mingw73_64\include\QtWidgets -I........\Qt\5.13.2\mingw73_64\include\QtGui -I........\Qt\5.13.2\mingw73_64\include\QtANGLE -I........\Qt\5.13.2\mingw73_64\include\QtCore -Idebug -I. -I/include -I........\Qt\5.13.2\mingw73_64\mkspecs\win32-g++
          LINKER = g++
          LFLAGS = -Wl,-subsystem,windows -mthreads
          LIBS = C:\Qt\5.13.2\mingw73_64\lib\libQt5Widgetsd.a C:\Qt\5.13.2\mingw73_64\lib\libQt5Guid.a C:\Qt\5.13.2\mingw73_64\lib\libQt5Cored.a debug\dirtyphp-gui_resource_res.o -lmingw32 C:\Qt\5.13.2\mingw73_64\lib\libqtmaind.a -LC:\openssl\lib -LC:\Utils\my_sql\mysql-5.7.25-winx64\lib -LC:\Utils\postgresql\pgsql\lib -lshell32
          QMAKE = C:\Qt\5.13.2\mingw73_64\bin\qmake.exe
          IDC = idc
          IDL = midl
          ZIP = zip -r -9
          DEF_FILE =
          RES_FILE = debug\dirtyphp-gui_resource_res.o
          COPY = copy /y
          SED = $(QMAKE) -install sed
          COPY_FILE = copy /y
          COPY_DIR = xcopy /s /q /y /i
          DEL_FILE = del
          DEL_DIR = rmdir
          MOVE = move
          CHK_DIR_EXISTS= if not exist
          MKDIR = mkdir
          INSTALL_FILE = copy /y
          INSTALL_PROGRAM = copy /y
          INSTALL_DIR = xcopy /s /q /y /i
          QINSTALL = C:\Qt\5.13.2\mingw73_64\bin\qmake.exe -install qinstall
          QINSTALL_PROGRAM = C:\Qt\5.13.2\mingw73_64\bin\qmake.exe -install qinstall -exe

          C Offline
          C Offline
          ChrisW67
          wrote on last edited by
          #20

          @Robert-M said in Qt5 C++ application compilation from prompt:

          C:\Users\lenovo>g++ --version
          g++ (i686-posix-dwarf-rev0, Built by MinGW-W64 project) 8.1.0

          OK. So when your make command invokes g++ it might be getting this version

          In Qt Creator I see:
          C:\Qt\Tools\mingw730_32\bin\g++.exe
          C:\Qt\Tools\mingw730_64\bin\g++.exe
          C:\Qt\Tools\mingw900_64\bin\g++.exe

          And you appear to have two other g++ versions present on your machine

          In make file I see:
          CC = gcc
          CXX = g++
          ...
          INCPATH = -I. -I........\Qt\5.13.2\mingw73_64\include -I........\Qt\5.13.2\mingw73_64\include\QtWidgets -I........\Qt\5.13.2\mingw73_64\include\QtGui -I........\Qt\5.13.2\mingw73_64\include\QtANGLE -I........\Qt\5.13.2\mingw73_64\include\QtCore -Idebug -I. -I/include -I........\Qt\5.13.2\mingw73_64\mkspecs\win32-g++

          The qmake command that built this makefile is expecting g++ to invoke version 7.3 64Bit and link against Qt libraries built with GCC 7.3 64Bit.
          It is possible that GCC 7 and GCC 8 libraries are binary incompatible (do not know, haven't looked) and thisnis the cause of the link-time issue.

          Try:

          set PATH=C:\Qt\Tools\mingw730_64\bin;%PATH%
          mingw32-make clean
          mingw32-make
          
          1 Reply Last reply
          0
          • 8Observer88 Offline
            8Observer88 Offline
            8Observer8
            wrote on last edited by 8Observer8
            #21

            @jsulm said in Qt5 C++ application compilation from prompt:

            QT += widgets

            Sorry. I forgot about it.

            QT += core gui widgets
            
            R 1 Reply Last reply
            0
            • 8Observer88 8Observer8

              @jsulm said in Qt5 C++ application compilation from prompt:

              QT += widgets

              Sorry. I forgot about it.

              QT += core gui widgets
              
              R Offline
              R Offline
              Robert M.
              wrote on last edited by
              #22

              @8Observer8
              OK.
              undefined reference

              jsulmJ 8Observer88 2 Replies Last reply
              0
              • R Robert M.

                @8Observer8
                OK.
                undefined reference

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #23

                @Robert-M said in Qt5 C++ application compilation from prompt:

                undefined reference

                Would you mind to provide more information or how are others supposed to help you based on that information?

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1
                • R Robert M.

                  @8Observer8
                  OK.
                  undefined reference

                  8Observer88 Offline
                  8Observer88 Offline
                  8Observer8
                  wrote on last edited by 8Observer8
                  #24

                  @Robert-M, сould you show your current .pro file in full?

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    Robert M.
                    wrote on last edited by
                    #25

                    QT += core gui widgets

                    CONFIG += c++11

                    SOURCES +=
                    main.cpp

                    TARGET = app

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      ChrisW67
                      wrote on last edited by
                      #26

                      @Robert-M Have you tried forcing the correct compiler/linker as I requested a few days back?

                      R 1 Reply Last reply
                      0
                      • C ChrisW67

                        @Robert-M Have you tried forcing the correct compiler/linker as I requested a few days back?

                        R Offline
                        R Offline
                        Robert M.
                        wrote on last edited by
                        #27

                        @ChrisW67
                        Thanks for help. Program compiles without problem.

                        1 Reply Last reply
                        0

                        • Login

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