Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Problem with .exe file

ABDUL HAYEEABDUL HAYEE Posts: 81Member
Dear Sir ,
I did not find a plateform for Visual C++ , so it is being posted here. After writung the code for File Assgt02_2B . There was no compiler error. But when i tried to build the rest of file , I recieved an arror , telling " CANNOT OPEN .EXE FILE" . The set of displayed messages is listed below .


(1) -------Configuration: Assgt02_2B - Win32 Debug------
Compiling...
Skipping... (no relevant changes detected)
Assgt02_2B.cpp

Assgt02_2B.obj - 0 error(s), 0 warning(s)


(2) -------Configuration: Assgt02_2B - Win32 Debug-------
Linking...
LINK : fatal error LNK1104: cannot open file "Debug/Assgt02_2B.exe"
Error executing link.exe.

Assgt02_2B.exe - 1 error(s), 0 warning(s)
------------
(3)

one or more files are out of date or do not exist
These files need to be rebuilt
DebugAssgt02_2B.exe

Will you like to build them ?
< Yes > < No > < Cancel >
------------------
CLICKED < YES > SAME MESSAGE IS DISPLAYED AGAIN
------------------

(4) ------Configuration: Assgt02_2B - Win32 Debug------
Linking...
LINK : fatal error LNK1104: cannot open file "Debug/Assgt02_2B.exe"
Error executing link.exe.

Assgt02_2B.exe - 1 error(s), 0 warning(s)

-----------------
MY QUERY IS IS TO KNOW WHY THE SYSRTEM IS NOT BUILDING THE FILE. IS THERE SOME SYNTEX OR CODING FAULT . i COULD NOT LOCATE THE ERROR.
SECONDLY WHAT IS THE MOST COMMON ERROR COMMITED BY BEGINNERS LIKE ME THAT CAUSES SUCH FAOLTS. AND WHAT IS THE REMDY. WHERE SHOULD I LOOK FOR ?
tHE CODE ALSO WRITTEN FOR READY REFRENCE;
( THE CODE ) ----------------------------------------------
/* 786 */
/* Assgt 02_2(ii) */

#include

LRESULT CALLBACK myWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);


int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
WNDCLASS wc;
ATOM classAtom;
HWND hWnd;
MSG msg;

wc.style = CS_NOCLOSE;
wc.lpfnWndProc = myWindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_HELP);
wc.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "TestWindowClass";

classAtom = RegisterClass(&wc);

if(!classAtom)
MessageBox(NULL, " Test Window class can not be registered", "Error", MB_OK); // error registering the window class

hWnd = CreateWindow("TestWindowClass", "First Test Window",
WS_OVERLAPPEDWINDOW | WS_VISIBLE | CS_HREDRAW | CS_VREDRAW |CS_NOCLOSE |WS_HSCROLL |WS_VSCROLL,
CW_USEDEFAULT, CW_USEDEFAULT, 340, 180, NULL, NULL, hInstance, NULL);

if(!hWnd)
MessageBox(NULL, " First Test Window, can not be created", "Error", MB_OK);


while(GetMessage(&msg, NULL, 0, 0) > 0)
{

TranslateMessage(&msg);
DispatchMessage(&msg);
}

return msg.wParam;
}

LRESULT CALLBACK myWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_LBUTTONDOWN:
{
MessageBox(hWnd, "Left mouse button pressed", "VU",0 ) ;
return 0 ;
}

case WM_DESTROY:
PostQuitMessage(0);
break;

default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}


Comments

  • stephlstephl Posts: 422Member
    : Dear Sir ,
    : I did not find a plateform for Visual C++ , so it is being posted here. After writung the code for File Assgt02_2B . There was no compiler error. But when i tried to build the rest of file , I recieved an arror , telling " CANNOT OPEN .EXE FILE" . The set of displayed messages is listed below .
    :
    :
    : (1) -------Configuration: Assgt02_2B - Win32 Debug------
    : Compiling...
    : Skipping... (no relevant changes detected)
    : Assgt02_2B.cpp
    :
    : Assgt02_2B.obj - 0 error(s), 0 warning(s)
    :
    :
    : (2) -------Configuration: Assgt02_2B - Win32 Debug-------
    : Linking...
    : LINK : fatal error LNK1104: cannot open file "Debug/Assgt02_2B.exe"
    : Error executing link.exe.
    :
    : Assgt02_2B.exe - 1 error(s), 0 warning(s)
    : ------------
    : (3)
    :
    : one or more files are out of date or do not exist
    : These files need to be rebuilt
    : DebugAssgt02_2B.exe
    :
    : Will you like to build them ?
    : < Yes > < No > < Cancel >
    : ------------------
    : CLICKED < YES > SAME MESSAGE IS DISPLAYED AGAIN
    : ------------------
    :
    : (4) ------Configuration: Assgt02_2B - Win32 Debug------
    : Linking...
    : LINK : fatal error LNK1104: cannot open file "Debug/Assgt02_2B.exe"
    : Error executing link.exe.
    :
    : Assgt02_2B.exe - 1 error(s), 0 warning(s)
    :
    : -----------------
    : MY QUERY IS IS TO KNOW WHY THE SYSRTEM IS NOT BUILDING THE FILE. IS THERE SOME SYNTEX OR CODING FAULT . i COULD NOT LOCATE THE ERROR.
    : SECONDLY WHAT IS THE MOST COMMON ERROR COMMITED BY BEGINNERS LIKE ME THAT CAUSES SUCH FAOLTS. AND WHAT IS THE REMDY. WHERE SHOULD I LOOK FOR ?
    : tHE CODE ALSO WRITTEN FOR READY REFRENCE;
    : ( THE CODE ) ----------------------------------------------
    : /* 786 */
    : /* Assgt 02_2(ii) */
    :
    : #include
    :
    : LRESULT CALLBACK myWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
    :
    :
    : int WINAPI WinMain(HINSTANCE hInstance,
    : HINSTANCE hPrevInstance,
    : LPSTR lpCmdLine,
    : int nCmdShow)
    : {
    : WNDCLASS wc;
    : ATOM classAtom;
    : HWND hWnd;
    : MSG msg;
    :
    : wc.style = CS_NOCLOSE;
    : wc.lpfnWndProc = myWindowProc;
    : wc.cbClsExtra = 0;
    : wc.cbWndExtra = 0;
    : wc.hInstance = hInstance;
    : wc.hIcon = NULL;
    : wc.hCursor = LoadCursor(NULL, IDC_HELP);
    : wc.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH);
    : wc.lpszMenuName = NULL;
    : wc.lpszClassName = "TestWindowClass";
    :
    : classAtom = RegisterClass(&wc);
    :
    : if(!classAtom)
    : MessageBox(NULL, " Test Window class can not be registered", "Error", MB_OK); // error registering the window class
    :
    : hWnd = CreateWindow("TestWindowClass", "First Test Window",
    : WS_OVERLAPPEDWINDOW | WS_VISIBLE | CS_HREDRAW | CS_VREDRAW |CS_NOCLOSE |WS_HSCROLL |WS_VSCROLL,
    : CW_USEDEFAULT, CW_USEDEFAULT, 340, 180, NULL, NULL, hInstance, NULL);
    :
    : if(!hWnd)
    : MessageBox(NULL, " First Test Window, can not be created", "Error", MB_OK);
    :
    :
    : while(GetMessage(&msg, NULL, 0, 0) > 0)
    : {
    :
    : TranslateMessage(&msg);
    : DispatchMessage(&msg);
    : }
    :
    : return msg.wParam;
    : }
    :
    : LRESULT CALLBACK myWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    : {
    : switch (message)
    : {
    : case WM_LBUTTONDOWN:
    : {
    : MessageBox(hWnd, "Left mouse button pressed", "VU",0 ) ;
    : return 0 ;
    : }
    :
    : case WM_DESTROY:
    : PostQuitMessage(0);
    : break;
    :
    : default:
    : return DefWindowProc(hWnd, message, wParam, lParam);
    : }
    : return 0;
    : }
    :
    :
    Well, I did not read your code but it seems you only have one cpp file in your project. If the compiler does not say anything, the error is not a syntax error. I know that this linker error can occur when the EXE file is still running. If it is not the case, you may try to delete all the files in the directory except the CPP one. Then try to build again. The error may be due to a damaged file that was produced by the linker and that is still used by the linker. Deleting all the files in the directory ensures that the compiler and linker really start a new building.
    If all this does not work, try to check the compiler and linker options in your environment.

    Steph
Sign In or Register to comment.