1
votes

I downloaded CodeBlocks and cut and pasted and program I had written earlier which I stored in the Codeblocks folder

The program is simple enough.

    #include <iostream>

    using namespace std;

    int main(){
         cout << "Hello. Watch this space.";
          return -1;
    }

However when I try to compile this program I get this message:

ld.exe||cannot open output file C:\Program Files (x86)\CodeBlocks\MyPrograms\HelloAll.exe Permission denied| ||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 3 second(s)) ===|

Could somebody please explain what this problem is and how I could fix it?

1
make sure you have file permissions for the path C:\Program Files (x86)\CodeBlocks\MyPrograms\ - NSjonas
Don't store documents or projects under Program Files. That is/should be read-only for most processes. - crashmstr
Have you tried running the program as administrator? - dx4
@dx4: Have you tried juggling angry badgers? That's a lot safer than running arbitrary code as administrator. - Mike Seymour

1 Answers

4
votes

This is an OS-level permission failure as CodeBlocks running under your user does not have access rights to write to C:\Program Files (x86)\CodeBlocks\MyPrograms\.

You should set the output directory to be one you can write to.