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. Want App, but Qt is creating a DLL instead
Forum Update on Monday, May 27th 2025

Want App, but Qt is creating a DLL instead

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 453 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.
  • H Offline
    H Offline
    harveyab
    wrote on last edited by harveyab
    #1

    I am using Qt Creator 2.8.84 (3.0.0-rc1) for IDE only on Windows XP.
    The compiler is MinGW gcc (or g++) which was part of a Pelles C CodeBlocks installation.
    With this code, I get a bad .exe file.
    It looks like it is creating a dll, but I want an App.
    I know I should be linking with some libraries, but I don't know which ones or how to specify them.
    Should I be using CMake instead?

    # IFW32.pro
    
    CONFIG -= qt
    CONFIG -= app_bundle
    
    # To stop this error: undefined reference to 'WinMain@16'
    win32:QMAKE_LFLAGS += -shared
    
    SOURCES += main.c
    

    C Source file:

    // main.c
    
    #include <windows.h>
    
    int WINAPI wWinMain(HINSTANCE i, HINSTANCE pi, PWSTR szCmdLine, int cs)
    {
      MessageBoxW(NULL, szCmdLine, L"Win32 Test", MB_OK);
    
      return 0;
    }
    

    Output:

    Starting C:\Documents and Settings\Owner\A_IFW32\debug\IFW32.exe...
    Failed to start program. Path or permissions wrong?
    C:\Documents and Settings\Owner\A_IFW32\debug\IFW32.exe exited with code -1
    

    When I look in the .exe file with exeinfo.exe, I see:

    Characteristics            : 
     * The file is a dynamic-link library
    
    aha_1980A 1 Reply Last reply
    0
    • H harveyab

      I am using Qt Creator 2.8.84 (3.0.0-rc1) for IDE only on Windows XP.
      The compiler is MinGW gcc (or g++) which was part of a Pelles C CodeBlocks installation.
      With this code, I get a bad .exe file.
      It looks like it is creating a dll, but I want an App.
      I know I should be linking with some libraries, but I don't know which ones or how to specify them.
      Should I be using CMake instead?

      # IFW32.pro
      
      CONFIG -= qt
      CONFIG -= app_bundle
      
      # To stop this error: undefined reference to 'WinMain@16'
      win32:QMAKE_LFLAGS += -shared
      
      SOURCES += main.c
      

      C Source file:

      // main.c
      
      #include <windows.h>
      
      int WINAPI wWinMain(HINSTANCE i, HINSTANCE pi, PWSTR szCmdLine, int cs)
      {
        MessageBoxW(NULL, szCmdLine, L"Win32 Test", MB_OK);
      
        return 0;
      }
      

      Output:

      Starting C:\Documents and Settings\Owner\A_IFW32\debug\IFW32.exe...
      Failed to start program. Path or permissions wrong?
      C:\Documents and Settings\Owner\A_IFW32\debug\IFW32.exe exited with code -1
      

      When I look in the .exe file with exeinfo.exe, I see:

      Characteristics            : 
       * The file is a dynamic-link library
      
      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by aha_1980
      #2

      @harveyab

      To stop this error: undefined reference to 'WinMain@16'
      win32:QMAKE_LFLAGS += -shared

      This is your problem.

      You need to call your main function WinMain, not wWinMain

      Qt has to stay free or it will die.

      H 1 Reply Last reply
      4
      • aha_1980A aha_1980

        @harveyab

        To stop this error: undefined reference to 'WinMain@16'
        win32:QMAKE_LFLAGS += -shared

        This is your problem.

        You need to call your main function WinMain, not wWinMain

        H Offline
        H Offline
        harveyab
        wrote on last edited by
        #3

        @aha_1980 Thank you. That fixed both problems, but printed garbage until I changed to MessageBoxA() and fixed the pointer sizes and types. Here is the final two files:

        IFW32.pro

        CONFIG -= qt
        CONFIG -= app_bundle
        SOURCES += main.c
        

        main.c

        #include <windows.h>
        int WINAPI WinMain(HINSTANCE i, HINSTANCE pi, LPSTR szCmdLine, int cs)
        {
          MessageBoxA(NULL, szCmdLine, "Win32 Prog", MB_OK);
          return 0;
        }
        
        JKSHJ 1 Reply Last reply
        1
        • H harveyab

          @aha_1980 Thank you. That fixed both problems, but printed garbage until I changed to MessageBoxA() and fixed the pointer sizes and types. Here is the final two files:

          IFW32.pro

          CONFIG -= qt
          CONFIG -= app_bundle
          SOURCES += main.c
          

          main.c

          #include <windows.h>
          int WINAPI WinMain(HINSTANCE i, HINSTANCE pi, LPSTR szCmdLine, int cs)
          {
            MessageBoxA(NULL, szCmdLine, "Win32 Prog", MB_OK);
            return 0;
          }
          
          JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by JKSH
          #4

          @harveyab said in Want App, but Qt is creating a DLL instead:

          CONFIG -= app_bundle
          

          You can also remove this line. It is only relevant on macOS, while you are targetting Windows only.

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          2

          • Login

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