I am getting this error when Trying to compile a simple Hello World! WIN32 Program:
Compiler: Default compiler
Building Makefile: "C:\Documents and Settings\Skipper\My Documents\C++ Files\First Project\Makefile.win"
Executing make...
make.exe -f "C:\Documents and Settings\Skipper\My Documents\C++ Files\First Project\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"
process_begin: CreateProcess(C:\DOCUME~1\Skipper\LOCALS~1\Temp\make27002.bat, C:\DOCUME~1\Skipper\LOCALS~1\Temp\make27002.bat, ...) failed.
make (e=32): The process cannot access the file because it is being used by another process.
make.exe: *** [main.o] Error 32
Execution terminated
And the Following is the Code that Lead to this error:
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
MSG Msg;
HWND hWnd;
WNDCLASSEX WndClsEx;
// Create the application window
WndClsEx.cbSize = sizeof(WNDCLASSEX);
WndClsEx.style = CS_HREDRAW | CS_VREDRAW;
WndClsEx.lpfnWndProc = WndProcedure;
WndClsEx.cbClsExtra = 0;
WndClsEx.cbWndExtra = 0;
WndClsEx.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WndClsEx.hCursor = LoadCursor(NULL, IDC_ARROW);
WndClsEx.hbrBackground = GetStockObject(BLUE_BRUSH);
WndClsEx.lpszMenuName = NULL;
WndClsEx.lpszClassName = ClsName;
WndClsEx.hInstance = hInstance;
WndClsEx.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
// Register the application
RegisterClassEx(&WndClsEx);
// Create the window object
hWnd = CreateWindow(ClsName,
WndName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
// Find out if the window was created
if( !hWnd ) // If the window was not created,
return 0; // stop the application
// Display the window to the user
ShowWindow(hWnd, SW_SHOWNORMAL);
UpdateWindow(hWnd);
// Decode and treat the messages
// as long as the application is running
while( GetMessage(&Msg, NULL, 0, 0) )
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
LRESULT CALLBACK WndProcedure(HWND hWnd, UINT Msg,
WPARAM wParam, LPARAM lParam)
{
switch(Msg)
{
// If the user wants to close the application
case WM_DESTROY:
// then close it
PostQuitMessage(WM_QUIT);
break;
default:
// Process the left-over messages
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
// If something was not done, let it go
return 0;
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am getting this error when Trying to compile a simple Hello World! WIN32 Program:
Compiler: Default compiler
Building Makefile: "C:\Documents and Settings\Skipper\My Documents\C++ Files\First Project\Makefile.win"
Executing make...
make.exe -f "C:\Documents and Settings\Skipper\My Documents\C++ Files\First Project\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"
process_begin: CreateProcess(C:\DOCUME~1\Skipper\LOCALS~1\Temp\make27002.bat, C:\DOCUME~1\Skipper\LOCALS~1\Temp\make27002.bat, ...) failed.
make (e=32): The process cannot access the file because it is being used by another process.
make.exe: *** [main.o] Error 32
Execution terminated
And the Following is the Code that Lead to this error:
include <windows.h>
const char ClsName = "BasicApp";
const char WndName = "A Simple Window";
LRESULT CALLBACK WndProcedure(HWND hWnd, UINT uMsg,
WPARAM wParam, LPARAM lParam);
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
MSG Msg;
HWND hWnd;
WNDCLASSEX WndClsEx;
}
LRESULT CALLBACK WndProcedure(HWND hWnd, UINT Msg,
WPARAM wParam, LPARAM lParam)
{
switch(Msg)
{
// If the user wants to close the application
case WM_DESTROY:
// then close it
PostQuitMessage(WM_QUIT);
break;
default:
// Process the left-over messages
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
// If something was not done, let it go
return 0;
}
I guess you missed the part about not creating projects in paths containing spaces when you read the "PLEASE READ BEFORE POSTING A QUESTION" thread?
Start by not creating your project in ""C:\Documents and Settings\Skipper\My Documents\C++ Files\First Project".
I suggest "C:\cpp_files\first_project\" instead.
Clifford