Build Problem

Whenever I attempt to compile my program, an error message comes up:

||=== Build: Debug in filename (compiler: GNU GCC Compiler) ===|
ld.exe||cannot open output file bin\Debug\AdvCalc.exe Permission denied|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

What is causing this?
Last edited on
Are you sure the program compiled without errors?

If it did you probably don't have write access rights to the directory in question. Where is your project located? What operating system are you using?
Last edited on
The project is located in a folder I have designated just for my coding on my desktop. The OS I have currently is Windows 8. It should have compiled without errors seeing as I had compiled it within the hour before this happened. I added a few lines of code that would loop a certain area of the code if the user designated for it to. I have looked over the lines multiple times and find nothing that should be a problem. Also I have tried removing those lines of code and running it, yet I run into the same problem.
Post the code.

Also do you have some kind of anti virus program running? If so you may need to tell the software not to scan your projects directory.

I see this often while at work because of the way our revision control system works.

Check to see if AdvCalc.exe already exists in the folder and is read only. That will give you permission trouble when trying to build it.
It isn't just a read only file. Also, I cannot place the code into this because it consists of over 38,000 characters and the max on here is 8192. This is a snippet of what I added. It was just the do while loops that I had added.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
                if (b==1)
                {
                    do
                    {
                        cout << "\n+-----Your Selection: Addition------+\n"
                             << "|      Enter Your Number to Add     |\n";
                        double c, d, sum;
                        cout << "                ";
                        cin >> c;
                        cout << "|      Enter Your Second Number     |\n"
                             << "                ";
                        cin >> d;
                        sum = c + d;
                        cout << "|             The Sum is            |\n"
                             << "                " << setprecision(4) << sum << endl
                             << "+-----------------------------------+\n"
                             << "\n+-----------------------------------+\n"
                             << "|     Would You Like to Continue    |\n"
                             << "|       Using Addition? (Y/N)       |\n"
                             << "                  ";
                        cin >> again;
                        cout << "+-----------------------------------+\n";
                    } while (again=='y' || again=='Y');

                }

                if (b==2)
                {
                    do
                    {
                        cout << "\n+----Your Selection: Subtraction----+\n"
                             << "|Enter Your Number to Subtract From |\n";
                        double e, f, diff;
                        cout << "                ";
                        cin >> e;
                        cout << "|   Enter Your Number to Subtract   |\n"
                             << "                ";
                        cin >> f;
                        diff = e - f;
                        cout << "|         The Difference is         |\n"
                             << "                " << setprecision(4) << diff << endl
                             << "+-----------------------------------+\n";
                        cout << "\n+-----------------------------------+\n"
                             << "|     Would You Like to Continue    |\n"
                             << "|      Using Subtraction? (Y/N)     |\n"
                             << "                  ";
                        cin >> again;
                        cout << "+-----------------------------------+\n";
                    } while (again=='y' || again=='Y');

                }

                if (b==3)
                {
                    do
                    {
                        cout << "\n+---Your Selection: Multiplication--+\n"
                             << "|   Enter Your Number To Multiply   |\n";
                        double g, h, prodct;
                        cout << "                ";
                        cin >> g;
                        cout << "|      Enter Your Second Number     |\n"
                             << "                ";
                        cin >> h;
                        prodct = g * h;
                        cout << "|           The Product is          |\n"
                             << "                " << setprecision(4) << prodct << endl
                             << "+-----------------------------------+\n";
                       cout << "\n+-----------------------------------+\n"
                             << "|     Would You Like to Continue    |\n"
                             << "|    Using Multiplication? (Y/N)    |\n"
                             << "                  ";
                        cin >> again;
                        cout << "+-----------------------------------+\n";
                    } while (again=='y' || again=='Y');

                }

                if (b==4)
                {
                    do
                    {
                        cout << "\n+------Your Selection: Division-----+\n"
                             << "|  Enter Your Number to Divide From |\n";
                        double i, j, quotent;
                        cout << "                ";
                        cin >> i;
                        cout << "|      Enter Your Second Number     |\n"
                             << "                ";
                        cin >> j;

                        do
                        {
                            if(j==0)
                            {
                                cout << "|              !Error!              |\n"
                                     << "|        !Cannot Divide by 0!       |\n"
                                     << "|      !Re-Enter Second Number!     |\n"
                                     << "                ";
                                cin >> j;
                            }

                        } while (j==0);

                        quotent = i / j;
                        if(j != 0)
                        {
                            cout << "|          The Quotient is          |\n"
                                 << "                " << setprecision(4) << quotent << endl
                                 << "+-----------------------------------+\n";
                        }

                        cout << "\n+-----------------------------------+\n"
                             << "|     Would You Like to Continue    |\n"
                             << "|       Using Division? (Y/N)       |\n"
                             << "                  ";
                        cin >> again;
                        cout << "+-----------------------------------+\n";
                    } while (again=='y' || again=='Y');


Also, if you're wondering, everything used is defined. Again is defined as a Char at the beginning of the main.
Last edited on
You really should be considering breaking this up into functions. For example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <iomanip>

using namespace std;

void doAddition()
{
   char again;
   do
   {
      cout << "\n+-----Your Selection: Addition------+\n"
           << "|      Enter Your Number to Add     |\n";
      double c, d, sum;
      cout << "                ";
      cin >> c;
      cout << "|      Enter Your Second Number     |\n"
           << "                ";
      cin >> d;
      sum = c + d;
      cout << "|             The Sum is            |\n"
           << "                " << setprecision(4) << sum << endl
           << "+-----------------------------------+\n"
           << "\n+-----------------------------------+\n"
           << "|     Would You Like to Continue    |\n"
           << "|       Using Addition? (Y/N)       |\n"
           << "                  ";
      cin >> again;
      cout << "+-----------------------------------+\n";
   } while (again=='y' || again=='Y');

}

int main()
{
   doAddition();

   return 0;

}


This way you can write each section of the code and troubleshoot it before you add it to the "big picture".


Also if you added all that code before you compiled the program, that is part of the problem. You need to compile often, many times after adding only one line of code. And always fix all warnings before you move to the next addition.

@jlb: The program is compiling ( and linking ) just fine. The problem is that the executable can not be created.

Other than what Jaybob66 suggested, is an earlier build of you program already running? This will make it impossible to write to the executable.
jlb, all I added to it was the do while statements. I had the rest already coded and had been compiled a ton of times considering this is towards the beginning of the rest of what it is capable of. @LowestOne no other build of the program is open or running. I have attempted restarting the program, my computer and have accomplished nothing.
Topic archived. No new replies allowed.