Note that there are some explanatory texts on larger screens.

plurals
  1. POUndefined reference to WinMain@16 in C++
    primarykey
    data
    text
    <p>i was taking the MSDN lesson for programming windows with C++ so i tried their code:</p> <pre><code>#ifndef UNICODE #define UNICODE #endif #include &lt;windows.h&gt; LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow) { // Register the window class. const wchar_t CLASS_NAME[] = L"Sample Window Class"; WNDCLASS wc = { }; wc.lpfnWndProc = WindowProc; wc.hInstance = hInstance; wc.lpszClassName = CLASS_NAME; RegisterClass(&amp;wc); // Create the window. HWND hwnd = CreateWindowEx( 0, // Optional window styles. CLASS_NAME, // Window class L"Learn to Program Windows", // Window text WS_OVERLAPPEDWINDOW, // Window style // Size and position CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, // Parent window NULL, // Menu hInstance, // Instance handle NULL // Additional application data ); if (hwnd == NULL) { return 0; } ShowWindow(hwnd, nCmdShow); // Run the message loop. MSG msg = { }; while (GetMessage(&amp;msg, NULL, 0, 0)) { TranslateMessage(&amp;msg); DispatchMessage(&amp;msg); } return 0; } LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_DESTROY: PostQuitMessage(0); return 0; case WM_PAINT: { PAINTSTRUCT ps; HDC hdc = BeginPaint(hwnd, &amp;ps); FillRect(hdc, &amp;ps.rcPaint, (HBRUSH) (COLOR_WINDOW+1)); EndPaint(hwnd, &amp;ps); } return 0; } return DefWindowProc(hwnd, uMsg, wParam, lParam); </code></pre> <p>}</p> <p>as i was compiling it as:</p> <pre><code>g++ -c app.cpp -s app.o g++ -o app.exe app.o -s -Wl,--subsystem,windows </code></pre> <p>then i get the error:</p> <pre><code> undefined reference to WinMain@16 </code></pre> <p>what's lacking?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload