0
votes

I have used Code blocks IDE for about a week now, and all worked fine until yesterday when I tried to build this code:

#include <iostream>

using namespace std;

int main()
{
  int sum = 0 , value = 0;

  while(cin >> value){
    sum += value;

    cout << "summen er: " << endl;
    cout << sum <<endl;
  }
  return 0;
}

Which resulted in the following build log:

(x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/../../../../mingw32/bin/ld.exe: cannot open output file bin\Debug\While_input.exe: Permission denied

collect2.exe: error: ld returned 1 exit status

Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))

I can no longer compile and run any code neither older projects which earlier this week worked fine.

I googled the problem and tried the following solutions:

  • run Code Blocks as admin
  • switch of Firewall
  • re install Code blocks
  • use task manager to see whether my application was still running.

So far nothing has worked. Does anyone know how I can fix this?

3
And you don't have the program already running and lingering in the background? - Some programmer dude
Does "clean" work, i.e. is the While_input.exe removed? - Niall
No it is not. yeah there is no while_input.exe file in the project folder. - user2987949
On Windows, you can't overwrite a program that is already running. That means you can't build if it's running, because then you get the error you have. You should look in the task-manager to see if it's running, and if it is then kill it. - Some programmer dude
but the problem is that it isn't as far as I can tell running. - user2987949

3 Answers

0
votes

This program works well in my computer.

  1. There is no prompt for input in your program. The program when run in C++ mode shows a cursor. Enter a simple number and enter, it just reproduces the value.
  2. Code blocks sometimes saves files as default in C rather than CPP. Have you tried saving as .cpp? John
0
votes

I will do this:

  1. Restart your pc
  2. Clean completely your folder leaving only the source files
  3. Build it again
  4. Run the program
0
votes

ld errors are due to linking problems. Please check suggestion in this link: C++ program does not run in Code::Blocks

I assume that you are using windows. Uninstall previous installation of codeblocks, You may need to delete the code blocks folder from C:/Users/"YourName(Admin)"/AppData/Roaming (You can make this file visible by going to windows search->folder options->View-> show hidden files, folders and drives). Now, try downloading the "codeblocks-13.12mingw-setup.exe" from the code blocks download page(http://www.codeblocks.org/downloads/binaries) and install fresh. Make sure the tool chain executable(settings -> compiler->Global compiler settings) shows Linker for dynamic and static libs. Best wishes.