0

If I have just run CodeBlocks, I can build and run the Hello world and I the prompt shows and everything is fine. I close it, change what is written, and this message appears: ld.exe||cannot open output file bin\Debug\HellowWorld.exe Permission denied|

I need to do way more difficults programs than a helloworld, and I've seen in several webs this problem addressed, but nothing works:

http://forums.codeblocks.org/index.php/topic,15047.30.html[1]

ld.exe: cannot open output file ... : Permission denied

After much reading, I understand it has something to do with how the program handles memory. It's something like, if it thinks there's still a process in execution, it does not let me build it again. But I do close it. I've tried everything: input any text so the windows closes (and it does), going to window task manager and finishing the process itself. It does not work. The kicker is that, if I let a few minutes pass, I can indeed build again and run it again. It's kinda stupid and I need help to fix this.

Even more links: The first one I don't get it. I downloaded it and checked as it's said in the wiki:

http://wiki.codeblocks.org/index.php?title=Creating_a_new_project[3]

The link:

http://www.reddit.com/r/learnprogramming/comments/1rvmhx/i_just_started_programming_and_stuck_from/[4]

I mean, I can have done wrong even that. But it does compile and build and run the first time arround...

Community
  • 1
  • 1
keont
  • 653
  • 1
  • 9
  • 26
  • Did you close the shell/gui of the hello world or w/e program? Otherwise check taskmanager or comprable depending on your os. Sounds like it is still open, hence the file lock. – IdusOrtus Oct 25 '14 at 10:11
  • Yes, I did both. I close it using the X on the top right corner, and with windows task manager, checking it both when it's still running, and what happens when I shut down the process. The process dies, but I still can't build and run, many times. If I let some time pass, I some times can. – keont Oct 25 '14 at 11:19

1 Answers1

0

Most likely the program is still running. Then you can't replace its executable.

If it doesn't have a visible user interface then you can forcefully terminate it via Task Manager Shift+Ctrl+Esc.

Or simpler, always build as console program, because then you can just close the program's console window.

Cheers and hth. - Alf
  • 142,714
  • 15
  • 209
  • 331
  • I thought I had commented on that, I have checked that. The process is not there, I kill it. After some time I can build and run again, but not right after I close the window, using any method of closing it. How would I build as console program? I mean... if later on I need to use makefiles and such, isn't console going to be a bit slower? – keont Oct 25 '14 at 11:21
  • Console isn't going to be slower in any way, but it's not a good idea for a final product since it offers an easy way to inadvertently terminate the program without giving it any chance to clean up. With g++ you can just use the `-mwindows` linking option. Or more directly `-subsystem windows`, IIRC (google it). You can set those options in the project build properties. – Cheers and hth. - Alf Oct 25 '14 at 11:42