Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C++ (http://www.programmingforums.org/forum15.html)
-   -   Cannot open output file error (http://www.programmingforums.org/showthread.php?t=13850)

PMAprogrammer Aug 25th, 2007 5:22 PM

Cannot open output file error
 
Hey guys,

My friend and I just recently started creating a win32 application in Codeblocks IDE. To start we created the simplest window you can make. It does nothing except draw itself on the screen and wait for someone to close it. Codeblocks lets me compile/run my program only once though. When my program executes I exit properly and codeblocks tells me that the process terminated. The thing is, every time after that when I try to compile it gives me this:

Switching to target: default
Linking executable: D:\Temp\Win32Test\Win32GUI.exe
D:\Apps\CodeBlocks\bin\..\lib\gcc\mingw32\3.4.4\..\..\..\..\mingw32\bin\ld.exe: cannot open output file D:\Temp\Win32Test\Win32GUI.exe: Invalid argument
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings

It seems as though after one execution of my program windows won't let go of the .exe file. I can't even go to the directory and delete it or anything. It just won't let me touch it. It only let's me compile the program once every time I start my computer..then it acts like I never closed the window and the program is still running. I'd love to be able to make more then one change to my program every time I turn my computer on :D . Any ideas?

Dameon Aug 25th, 2007 6:39 PM

Closing a window does not force a program to exit.

Firefox exits when all windows are closed. Others exit when the main window is closed. It is up to the programmer to handle the closing of windows appropriately such that the program exits in an expected way.


Check for your program in the task manager (ctrl+shift+esc), kill it, correct the code, and recompile.

PMAprogrammer Aug 25th, 2007 6:47 PM

I check for the running process all the time and it's never still running according to my task manager.

Sorry, I should have posted the way I handle the exit in the first post.

:

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(0);
                break;
            }
        default:
            // Process the left-over messages
            return DefWindowProc(hWnd, Msg, wParam, lParam);
    }
    // if something was not done, let it go
    return 0;
}


That's my function that responds to all events. When I click on the X in the upper right hand corner, my understanding is that windows fires a WM_DESTROY event to my program and then I handled it my posting a quit message which would close the program.

Even with all this the annoying behavior persists =/ :confused:

lectricpharaoh Aug 25th, 2007 7:39 PM

When you open up Task Manager, don't look on the 'Applications' tab. This only shows things that have a UI up and running. Look on the 'Processes' tab, and kill your app there.

PMAprogrammer Aug 25th, 2007 8:01 PM

Tried it but still no dice.

dr.p Aug 26th, 2007 1:31 AM

You might try handling the WM_CLOSE message in your WinProc function by calling DestroyWindow() and passing your main window handle to it.


All times are GMT -5. The time now is 3:10 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC