Author Topic: "Permission Denied" windows 7 / ld.exe problem  (Read 7669 times)

c-hippy

  • Guest
"Permission Denied" windows 7 / ld.exe problem
« on: March 27, 2016, 07:17:30 pm »
Hello.  I'm new to code::blocks and the forum.  I tried to resurrect an old thread on this topic, but was forced to start a new thread instead. 

I've seen numerous people, mostly (if not all) from newbies experiencing an issue where ld.exe throws a "Permission denied" error.  Output file is the culprit.  It's always been blamed on Windows, from what I've read, but I think it's more likely a combination of how C::B and Windows play together.  I suspect the problem can be fixed in any case, from within the C::B code.

Anyone ever figure out the cause of this or a proper fix?  I'm having the same problem, though I never run antivirus or firewall on my computer.  I run as administrator ALL the time.  And the project files are all in my user/documents folder.  (Windows 7-64 Pro).

I'd like to add my 2 cents (observations).  Though, I don't know how it should be remedied or what software (or OS) is responsible.  Maybe someone here will be able to adequately shed some light on that.

To restate the problem:

Windows 7 (others?)
No Anti-virus
No Firewall
Copied "Hello World" console project from a popular tutorial
User is logged in as administrator
Project folder is in User/documents folder
UAC is turned off.
The output file process is NOT open in task manager

Steps to repeat error:

- Click "Build and run" button
- Program runs
- Exit program normally
- Console closes
- Make ANY change in the editor (Add a single letter to a remark, add a white space, insert a blank line... just about anything seems to work)
- Click "Build and run" button immediately
- "Permission Denied" caused by windows not allowing access (renaming, deleting, copy over etc) to the output file ("my_project.exe")  ld.exe will throw an error as a result.  Note: With Windows Explorer open and looking at the folder where the output file is located, the OS will not permit access to the file, however, the folder is fully accessible (add a new folder as a sibling to the output file for example). 

My investigation indicates that this is a time based error.  If you wait approximately 1.5 minutes (on my computer) AFTER the very first character has changed in the IDE, the output file WILL disappear in Windows Explorer, at which time, "Build and Run" button will work, ld.exe will link and the program will run.  This is why it SEEMS to be a random or intermittent problem.  Perhaps it has something to do with how Windows collects garbage.  But, I suspect that something in C::B is not releasing the file, probably for the sake of saving time by reusing the existing output file rather than rebuilding it from scratch when NO changes are made to the source.  The reason I say this is because, if after clicking the "build and run" button AND exiting the program (the output file) normally, but BEFORE ANY CHANGES are made to the source code, the output file does NOT disappear (in Windows Explorer).  Further, immediately after exiting the console, Windows DOES permit (permission) the output file name to be changed!  Changing the file name THEN immediately making an edit to the source code in the IDE followed by clicking "Build and Run" results in a successful compile.  ld.exe does NOT throw an error.

To sum up, any change made to the text in the IDE is somehow locking out the user from the output file that exists from the previous "Build and Run," for about 1.5 minutes.  After that delay, everything works as it should.  This could explain why so many newbies (like me) are experiencing the problem while most experienced users aren't.  Newbies will, for example, make a quick change to the return value of a function and hit "build and run" to see what happens before that time delay has passed.  While an experienced coder might make several changes before debugging again, in which case time delay has lapsed.  But I think since entering a single keystroke in the IDE and immediately hitting "Build and Run" is causing this error, it is DEFINITELY C::B causing this behavior.

Thoughts?

Certainly, one can wait a couple minutes between "build and runs" but

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: "Permission Denied" windows 7 / ld.exe problem
« Reply #1 on: March 28, 2016, 12:48:57 am »
There was a Windows Service that someone suggested to turn on that a person had fix this error.

Edit: Next time I am on Windows I will look at my services and maybe I will recall the name.

Edit2: Found list of services online. Then, found CB link to confirm my guess of "Application Experience" was correct.
http://forums.codeblocks.org/index.php/topic,15047.msg116870.html#msg116870

Tim S.
« Last Edit: March 28, 2016, 01:01:40 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org