Windows source I found won't compile

Pages: 12
Hello. I found this code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifndef UNICODE
#define UNICODE
#endif 

#include <windows.h>

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(&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(&msg, NULL, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&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, &ps);



            FillRect(hdc, &ps.rcPaint, (HBRUSH) (COLOR_WINDOW+1));

            EndPaint(hwnd, &ps);
        }
        return 0;

    }
    return DefWindowProc(hwnd, uMsg, wParam, lParam);
}


at https://docs.microsoft.com/en-us/windows/win32/learnwin32/your-first-windows-program
And when I try to compile it I get an error:
undefined reference to WinMain

Note: I am using Dev-cpp because visual studio is to slow on load screen.

Can anyone help? Thanks in advance.
Last edited on
Option 1 - take these 3 lines out
1
2
3
#ifndef UNICODE
#define UNICODE
#endif  

And change wWinMain to WinMain

Option 2
Tell the rest of the tools in dev-cpp that you're building unicode windows applications. I don't know how (or if) you can do that.

> undefined reference to WinMain
In essence, you need to tell the linker to look for wWinMain, because that's the entry point to your code.


> I am using Dev-cpp
Which version?
If it's the bloodshed version, it's hopelessly out of date (by about 15 years).

This is better, but also starting to look like abandonware.
https://sourceforge.net/projects/orwelldevcpp/
I would recommend to forget the MS templates.
They are too complicated for beginners.
Dev-CPP comes with a template for Windows GUI.
This works out of the box.
DevCPP (both versions) are rather outdated for the C++ libraries. If you want an alternative to Visual Studio you might look at Code::Blocks. It is continuing to be updated, and the underlying compiler can be updated without too much hassle.

C::B can create console and Win32 GUI apps, as well as a number of other types including DLLs.

http://www.codeblocks.org/

Only Visual Studio AFAIK will understand the later additions to the Win32 API such as wWinMain (the Unicode version of the ANSI WinMain).
I tried Code::blocks just now and can't compile... Maybe I set it up wrong?
I'm in total agreement with Thomas1965. The templates provided by Microsoft, and their basic Win32 Api tutorials are overly complicated and confusing. To elaborate on my reason for saying this, I'm a 'minimalist' by nature. When I'm learning a new coding concept or paradigm, as you are Alexander, I want to see that concept illustrated in its barest and most simple form. Those Microsoft examples and templates run on for hundreds of lines of code seemingly. It simply doesn't take that many lines of code to put up a working window using Win32 techniques. Here is the code for a window in its barest and simplest form....

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// cl Main.cpp /FeForm1.exe /O1 /Os /link Kernel32.lib User32.lib 
#include <windows.h>

LRESULT CALLBACK fnWndProc(HWND hwnd, unsigned int msg, WPARAM wParam, LPARAM lParam)
{
 if(msg==WM_DESTROY)       // This is the Window Procedure.  The concept of the
 {                         // Window Procedure is the most important concept to
    PostQuitMessage(0);    // grasp in C/C++ WinApi coding.  You never call this
    return 0;              // function with your code; rather, Windows calls it
 }                         // to inform code here of events occurring.  The events
                           // are reported here as messages.
 return (DefWindowProc(hwnd, msg, wParam, lParam));
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevIns, LPSTR lpszArgument, int iShow)
{
 char szClassName[]="Form1";      // This will be both the name of the app and the name of
 WNDCLASSEX wc;                   // the main window's 'Window Class'.  The concept of the
 MSG messages;                    // Window Class and its associated Window Procedure are
 HWND hWnd;                       // the most important concepts in Windows Programming.

 memset(&wc,0,sizeof(wc));                     // zero out WNDCLASSEX wc
 wc.lpszClassName = szClassName;               // Feed "Form1" into WNDCLASSEX::lpszClassName
 wc.lpfnWndProc   = fnWndProc;                 // Feed pointer ( function address ) to Window Procedure
 wc.cbSize        = sizeof(WNDCLASSEX);        // Set Size
 wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW;   // Set Background HBRUSH (Handle To A BRUSH)
 wc.hInstance     = hInstance;                 // Set HANDLE To Instance (its a virtual process memory thing)
 RegisterClassEx(&wc);                         // Let Operating System know about "Form1" Class
 hWnd=CreateWindowEx(0,szClassName,szClassName,WS_OVERLAPPEDWINDOW,200,175,320,300,HWND_DESKTOP,0,hInstance,0);
 ShowWindow(hWnd,iShow);
 while(GetMessage(&messages,NULL,0,0))   // The message pump retrieves messages from the program's
 {                                       // message queue with GetMessage(), does some translation
    TranslateMessage(&messages);         // work in terms of character messages, then calls the
    DispatchMessage(&messages);          // Window Procedure associated with the HWND of the message
 }                                       // being processed.  Note that an app can have many Window
                                         // Procedures.
 return messages.wParam;
}


Here is the console output from compiling/linking this code in x64 Visual Studio 2019 build chain from the command line (command line string shown above)...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

C:\Code\CodeBlks\C++\Form1>cl Main.cpp /FeForm1.exe /O1 /Os /link Kernel32.lib User32.lib
Microsoft (R) C/C++ Optimizing Compiler Version 19.25.28614 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

Main.cpp
Microsoft (R) Incremental Linker Version 14.25.28614.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:Form1.exe
Kernel32.lib
User32.lib
Main.obj

C:\Code\CodeBlks\C++\Form1>
I see that's old code I dug up from some tutorials I wrote a long time ago. Still works fine in command line builds, but will cause hiccups when run in Visual Studio IDE due to propensity there to #define UNICODE. If you are learning this stuff the first thing you need to learn is the whole char verses wchar_t thing, and TCHARs, and what goes on in the Windows includes in terms of the 'W' verses 'A' function calls, and the macros that eliminate those function suffixes.
This'll build whether UNICODE is defined or not....

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// cl Main.cpp /FeForm1.exe /O1 /Os /link Kernel32.lib User32.lib 
#include <windows.h>
#include <tchar.h>

LRESULT CALLBACK fnWndProc(HWND hwnd, unsigned int msg, WPARAM wParam, LPARAM lParam)
{
 if(msg==WM_DESTROY)       // This is the Window Procedure.  The concept of the
 {                         // Window Procedure is the most important concept to
    PostQuitMessage(0);    // grasp in C/C++ WinApi coding.  You never call this
    return 0;              // function with your code; rather, Windows calls it
 }                         // to inform code here of events occurring.  The events
                           // are reported here as messages.
 return (DefWindowProc(hwnd, msg, wParam, lParam));
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevIns, LPSTR lpszArgument, int iShow)
{
 TCHAR szClassName[]=_T("Form1"); // This will be both the name of the app and the name of
 WNDCLASSEX wc;                   // the main window's 'Window Class'.  The concept of the
 MSG messages;                    // Window Class and its associated Window Procedure are
 HWND hWnd;                       // the most important concepts in Windows Programming.

 memset(&wc,0,sizeof(wc));                     // zero out WNDCLASSEX wc
 wc.lpszClassName = szClassName;               // Feed "Form1" into WNDCLASSEX::lpszClassName
 wc.lpfnWndProc   = fnWndProc;                 // Feed pointer ( function address ) to Window Procedure
 wc.cbSize        = sizeof(WNDCLASSEX);        // Set Size
 wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW;   // Set Background HBRUSH (Handle To A BRUSH)
 wc.hInstance     = hInstance;                 // Set HANDLE To Instance (its a virtual process memory thing)
 RegisterClassEx(&wc);                         // Let Operating System know about "Form1" Class
 hWnd=CreateWindowEx(0,szClassName,szClassName,WS_OVERLAPPEDWINDOW,200,175,320,300,HWND_DESKTOP,0,hInstance,0);
 ShowWindow(hWnd,iShow);
 while(GetMessage(&messages,NULL,0,0))   // The message pump retrieves messages from the program's
 {                                       // message queue with GetMessage(), does some translation
    TranslateMessage(&messages);         // work in terms of character messages, then calls the
    DispatchMessage(&messages);          // Window Procedure associated with the HWND of the message
 }                                       // being processed.  Note that an app can have many Window
                                         // Procedures.
 return messages.wParam;
}
See, that's 'minimalism'. The basic concept abstracted to its barest essence. No half dozen includes doing God knows what. No hundreds of lines of code. I'll tell you what always gets me about all these complicated templates I see. Its when they create seperate functions for the RegisterClassEx() call, and for the message pump. A RegisterClassEx() call can indeed fail at compile time if some of the critical fields of the WNDCLASSEX struct are not filled out. Have had it happen many times. But failing at runtime? Never seen it myself in x86. Likely possible in 16 bit Windows, but that was more than 25 years ago (Windows 3.1, etc). Its like these people start with something relatively simple and basic and try to see how confusing they can make it and how many extraneous lines of code they can add.
Last edited on
I just tested your program as posted above and it built and ran perfectly Alexander. Sorry about my rant above. Your program isn't bad at all - not like some I've seen. I named it Test.cpp. Here is the compiler output from VStudio 2019's compiler....

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

C:\Code\CodeBlks\C++\Form1>cl Test.cpp /O1 /Os /link Kernel32.lib User32.lib
Microsoft (R) C/C++ Optimizing Compiler Version 19.25.28614 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

Test.cpp
Microsoft (R) Incremental Linker Version 14.25.28614.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:Test.exe
Kernel32.lib
User32.lib
Test.obj

C:\Code\CodeBlks\C++\Form1>test

C:\Code\CodeBlks\C++\Form1>
It might help if you would post your error messages, or at least the gist of it. Sometimes they can be pretty repetitive.
Thanks. I will try Visual Studio 2019, but how do you compile without starting a project?
Last edited on
I just figured you were using Visual Studio 2019 because it seems everybody wants the latest version of everything. It really doesn't matter to me. Actually, VS 2008 is the version I use the most. There's nothing at all unusual about that program that wouldn't allow it to build going all the way back to Visual Studio 98 (1998 VC 6).

The problem with these IDE's is all the rig - a - ma role one needs to go through to set up a project. Best way is to tell the IDE one wants to set up a Win32 GUI project (as opposed to a console mode project), and tell it you want an 'empty project'. That way, it kind of discourages the IDE to auto-generate all these extra files filled with gobbledegook. Then use the IDE to 'Add Files' to the project. Put that source code of yours into a text file with a *.cpp extension, then add that to the project. Then simply build the project.

I only do command line compiling/linking. I'll give some explanation of that a bit later.
Ok, I tried your "barest and simplest form" and it made a window in Visual Studio 2019.

Thanks to everyone for their help!! :D
Edited to fix missing double quotes

This is the batch file I use for VSC++
works with VS 2015/2017/2019 Community only ( I think. I only have 2017/2019 presently)

Usage: VSCPP.BAT MainFile [con gui dll obj] extra files
Note: ExtraFiles can be .libs, .res , .obj
No extention .cpp is assumed
James

'==============================================================================
@setlocal enableextensions enabledelayedexpansion

@ECHO OFF

REM get just file name.
REM Note: because FN is set using %F% with quotes no need for quoted %FN%
REM ----------------------------
SET F=%~nx1
REM ----------------------------
REM See if we have a .cpp source
IF EXIST "%F%.cpp" (
SET FN="%F%.cpp"
GOTO start
)
GOTO usage

:start

IF [%2]==[] GOTO usage
IF [%3]==[] GOTO usage



REM param 4 -> Debug or Release
SET BUILD=%4

IF [%BUILD%]==[] (
SET BUILD=/MT
GOTO gotbuild
)

IF /I [%4] == [debug] (
SET BUILD=/MTd
GOTO gotbuild
)

IF /I [%4] == [release] SET BUILD=/MT

:gotbuild

IF /I [%2] == [-m32] (
SET XTYPE=x86
GOTO gotit
)
IF /I [%2] == [-m64] (
::SET XTYPE=x86_amd64
SET XTYPE=x64
)



:gotit

REM these next check for command line defines in the format /DMYEQUATE:1
REM you cannot use an "=" in batch files. ":" is substituted and changed to =

IF [%5]==[] GOTO setup
SET P5=%5
SET STR1=%5
IF NOT X%STR1:/D=%==X%STR1% (
SET P5=%STR1::==%
SET STR1=
)

IF [%6]==[] GOTO setup
SET P6=%6
SET STR1=%6
IF NOT X%STR1:/D=%==X%STR1% (
SET P6=%STR1::==%
SET STR1=
)

IF [%7]==[] GOTO setup
SET P6=%7
SET STR1=%7
IF NOT X%STR1:/D=%==X%STR1% (
SET P6=%STR1::==%
SET STR1=
)

IF [%8]==[] GOTO setup
SET P7=%8
SET STR1=%8
IF NOT X%STR1:/D=%==X%STR1% (
SET P7=%STR1::==%
SET STR1=
)



:setup
IF EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" (
ECHO Using Visual Studio BuildTools 2019
CALL "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" %XTYPE%
GOTO got_tools
)


IF EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" (
ECHO Using Visual Studio Cummunity 2019
CALL "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" %XTYPE%
GOTO got_tools
)

IF EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" (
ECHO Using Visual Studio BuildTools 2017
CALL "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" %XTYPE%
GOTO got_tools
)

IF EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" (
ECHO Using Visual Studio Cummunity 2017
CALL "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" %XTYPE%
GOTO got_tools
)

IF DEFINED VS140COMNTOOLS (
CALL "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" %XTYPE%
GOTO got_tools
)


ECHO For VS 2015/2017/2019 only
GOTO USAGE



:got_tools
REM place our include and lib folders before c++
SET INCLUDE=%~dp0include;%INCLUDE%
SET LIB=%~dp0;%LIB%

IF "%WARN%"=="" SET WARN=/W1


IF /I [%3] == [CON] (
SET SUBSYS= /SUBSYSTEM:CONSOLE
SET FTYPE=" a Windows Console App"
)

IF /I [%3] == [GUI] (
SET SUBSYS=/SUBSYSTEM:WINDOWS
SET FTYPE="a Windows Gui App"
)

IF /I [%3] == [DLL] (
SET SUBSYS=/DLL
SET FTYPE="a Windows DLL"
)

IF /I [%3] == [OBJ] (
SET SUBSYS=/DLL
SET FTYPE="a Windows Object File"
)

IF /I [%3] == [LIB] (
SET SUBSYS=/DLL
SET FTYPE="a Windows Static Library File"
)

REM --------------------------------------------------------------
REM always use the %F%.rc file in the Res Directory if it exists
REM this should handle both projects and individual files with resources

IF EXIST "res\%F%.rc" (
ECHO Compiling resources.....
cd res
Rc "%F%"
SET VRES="res\%F%.res"
cd ..
) ELSE (
IF EXIST "%F%.rc" (
ECHO Compiling resources.....
Rc "%F%"
SET VRES="%F%.res"
)
)
:: Windows 10
SET WIN_VER=/DWINVER=_WIN32_WINNT_WIN10 /D_WIN32_WINNT=_WIN32_WINNT_WIN10

REM --------------------------------------------------------------
ECHO Compiling %FN% To %FTYPE%
IF /I [%3]==[DLL] (
cl.exe %FN% %VRES% /EHsc /D %BUILD% %WIN_VER% /link /DLL /OUT:"%F%.dll"
GOTO cleanup
)

IF /I [%3]==[OBJ] (
cl.exe /c /O1 /Gd %WARN% /EHsc %BUILD% %FN% %WIN_VER% %P4% %P5% %P6% %P7% %P8%
GOTO cleanup
)
IF /I [%3]==[LIB] (
cl.exe /c /O1 /Gd %WARN% /EHsc %BUILD% %FN% %WIN_VER% %P4% %P5% %P6% %P7% %P8%
lib.exe %F%.obj
GOTO cleanup
)

REM Console and gui
:: cl.exe /O1 /Gd %WARN% /EHsc /MT %FN% /Fe"%F%.EXE" %WIN_VER% %VRES% %SUBSYSTEM% %P4% %P5% %P6% %P7% %P8% /nologo -std:c++14
:: cl.exe /O1 /Gd %WARN% /EHsc /MT %FN% /Fe"%F%.EXE" %WIN_VER% %VRES% %SUBSYSTEM% %P4% %P5% %P6% %P7% %P8% /nologo /std:c++latest

cl.exe /O1 /Gd %WARN% /EHsc /MT %FN% /Fe"%F%.EXE" %WIN_VER% %VRES% %SUBSYSTEM% %P4% %P5% %P6% %P7% %P8% /nologo /std:c++latest


:cleanup
ECHO Finished!
IF /I NOT [%3]==[OBJ] (
IF EXIST "%F%.obj" del "%F%.obj"
)
IF EXIST "%F%.res" del "%F%.res"
GOTO done
:usage
ECHO **************************************************************
ECHO Usage: VSCPP.BAT MainFile [con gui dll obj] extra files
ECHO Note: ExtraFiles can be .libs, .res , .obj
ECHO **************************************************************
:done
endlocal
Last edited on
James,

Please forgive me for confessing to you that, as many times as you've provided me your batch file, I've never used it - until now. I just tried a few times and couldn't get it to work. As I think you know, I only use the Visual Studio command prompt Microsoft puts on the Start menu group when a version of Visual Studio is installed. And I feed my command line string with all my desired compiler/linker switches into that. Of course, that's just a shortcut which invokes vcvarsall.bat (or whatever). Actually, thinking back on it, way back in VC6 (Visual Studio 98), I think I just opened a command prompt window of my own (not one provided by Microsoft or Visual Studio), and first invoked vcvars.bat directly to set the paths to the build tool chain, then entered my command line string.

I kind of figured your batch file was a replacement for vcvars or vcvarsall.bat? So what I tried first was to just open a command prompt window from the Start Menu - not the one provided by Visual Studio, and attempt to use your usage guidlines. But didn't seem to work. What I did exactly is this...

First I executed a ChDir (CD) command to change the directory to where I had a *.cpp source file, which looked like so....

CD C:\Code\CodeBlks\C++\Form1

My file was Main.cpp. I copied your batch file as you posted above and saved it as MSCPP.BAT, and I put it in my above described....

...\Form1

directory with the Main.cpp file. Then, using your 'Usage' guidlines, I tried this....

C:\Code\CodeBlks\C++\Form1>VSCPP.bat Main.cpp [GUI]

And nothing happened. No error messages, no exe production, no objs - nothing. I also tried a few other combinations. No luck.

So then I tried it from the Visual Studio command prompt. No better luck. Perhaps you can tell me (and others) how to use your batch file?

Here is the output from my console window....

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Microsoft Windows [Version 10.0.18362.1082]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\freddie>cd\

C:\>CD C:\Code\CodeBlks\C++\Form1

C:\Code\CodeBlks\C++\Form1>VSCPP.BAT Main.cpp [GUI]
**************************************************************
Usage: VSCPP.BAT MainFile [con gui dll obj] extra files
Note: ExtraFiles can be .libs, .res , .obj
**************************************************************

C:\Code\CodeBlks\C++\Form1>



Last edited on
Fred,
Yeah I messed up above. Missed the -m32|-m64. Sorry
See the first Usage and Note above. No ext
VSCPP.BAT Main -m64 gui

James
I'm getting closer James. Used this....

VSCPP.BAT Main gui -m64 [ENTER]

I used the command prompt from the VStudio 2019 installation. First changed directory to where Main.cpp was located. Got this console output...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

C:\Code\CodeBlks\C++\Form1>VSCPP.BAT Main gui -m64
Using Visual Studio BuildTools 2019
The system cannot find the path specified.
Compiling "Main.cpp" To
Main.cpp
Main.obj : error LNK2019: unresolved external symbol __imp_GetMessageA referenced in function WinMain
Main.obj : error LNK2019: unresolved external symbol __imp_TranslateMessage referenced in function WinMain
Main.obj : error LNK2019: unresolved external symbol __imp_DispatchMessageA referenced in function WinMain
Main.obj : error LNK2019: unresolved external symbol __imp_DefWindowProcA referenced in function "__int64 __cdecl fnWndProc(struct HWND__ *,unsigned int,unsigned __int64,__int64)" (?fnWndProc@@YA_JPEAUHWND__@@I_K_J@Z)
Main.obj : error LNK2019: unresolved external symbol __imp_PostQuitMessage referenced in function "__int64 __cdecl fnWndProc(struct HWND__ *,unsigned int,unsigned __int64,__int64)" (?fnWndProc@@YA_JPEAUHWND__@@I_K_J@Z)
Main.obj : error LNK2019: unresolved external symbol __imp_RegisterClassExA referenced in function WinMain
Main.obj : error LNK2019: unresolved external symbol __imp_CreateWindowExA referenced in function WinMain
Main.obj : error LNK2019: unresolved external symbol __imp_ShowWindow referenced in function WinMain
Main.EXE : fatal error LNK1120: 8 unresolved externals
Finished

C:\Code\CodeBlks\C++\Form1>


Only thing is, couldn't find Main.obj. 'Pears to me that should have been generated, as it appears compilation succeeded. Lin k failed though?
Fred,
First you should use a normal command prompt.
Next is how I code using this batch file. I list the libraries needed in the c++ source.
In this case:
#pragma comment(lib,"kernel32.lib")
#pragma comment(lib,"user32.lib")
I guess I could update it but I prefer this method.
My MinGW, Nuwen, TDMGCC batch files have a slew of libraries in the batch file itself as those compilers do not recognize the the #pragma comment(lib,"******")

James

Good enough James. I'll try it in a bit.

Fred
Pages: 12