0

I'm doing a test. I have created an empty qmake project with Qt creator. I added a file main.cpp. A small code in main.cpp just displays a button. I want to use the created main.o file to build the obtained application in Qt Creator. For this, I make links between the main.o file and the libraries indicated in the Makefile.Debug file. I do it in command line and I use mingw_64 Version 12.2.0 (not the one in the Qt folder) to make the links. The command I use is the following:

g++ main.o -LC:\Qt\6.4.0\mingw_64\lib -lQt6Widgets -lQt6Gui -lQt6Core -lQt6EntryPoint -o executabl_test

I get the following error:

undefined reference to `WinMain'

the complete output is the following:

C:/x86_64-12.2.0-release-posix-seh-rt_v10-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/x86_64-12.2.0-release-posix-seh-rt_v10-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o):crt0_c.c:(.text.startup+0x2e): undefined reference to `WinMain'
collect2.exe: error: ld returned 1 exit status

I also noticed that with or without the Qt6EntryPoint library I get the same error. I would like to know please what is the source of the problem and how to solve it. Some forums talk about this problem, but no solution is adapted to my case.

I don't know much about command line compilation and compilation in general. I'm just doing a test out of curiosity.

I am on Qt6

Thanks in advance.

Update: Here is the code

#include <QApplication>
#include <QPushButton>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);                

    QPushButton btn;                        
    btn.setText("QPusbutton");
    
    btn.show();
    return a.exec();
}

Here is the content of my .pro file

QT+= core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
CONFIG += c++17
    
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
SOURCES += \
    main.cpp \
Kev_
  • 29
  • 6

0 Answers0