C++ program builds but doesn't run

Hi all,

For about a week, I've been having this issue on my Windows 8.1 machine, where I can build a C++ program using Eclipse CDT, Visual Studio 2012 or Code::Blocks 12 & 13, but when I try to open the .exe file in Explorer, nothing happens.

I go to Task Manager, it's not there. Process Hacker 2 shows the application, but I can't terminate it and get the following error after my first attempt: "Unable to terminate HelloWorld.exe (PID 4016): An attempt was made to access an exiting process."

When I try to run the program using the debugger of one of said IDE's, I also get nothing. In Code::Blocks, the console window opens up, but nothing prints. Visual Studio debugger just crashes. Eclipse hangs at the "Launching" window.

I have tried the following (and more probably) so far with no luck:
- Re-building old projects that used to compile and run
- Writing simple HelloWorld programs
- Applying Windows .exe file association registry fix as described here: https://support.microsoft.com/en-us/kb/950505
- Trying out different compiler settings on Code::Blocks
- Re-downloading Code::Blocks 13, bundled with TDM-GCC 4.7.1 or 4.8.1
- Temporarily disabling Avast Antivirus
- Rebooting the computer

I should also mention that I haven't had the same issue when building C projects with Eclipse CDT and Code::Blocks.

Please forgive me if I'm not adhering to forum rules or if my post is incoherent. Any help will be greatly appreciated!
I don't know if I can help because I don't have Windows 8.1, but could you post a small example of something that won't run? Please, nothing with dependencies or thousands of lines of code.
I initially thought this might be a compiler issue, but I've tried a couple more things since, and that doesn't seem to be the case.

First, I realized I hadn't attempted to run existing programs without re-building, so I did that and had the exact same issue. Again, .exe's written in C have no issue.

Second, I tried a running program that wouldn't run on my machine on a Windows 7 machine, and it worked as it should.

Here's a sample of the neural network demo I wrote a while back and successfully ran on Windows 7:

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
#include <iostream>
#include "NeuralNetwork.h"

int main() {
    Network network({3, 3, 3});

    // layer 0 - 1
    network[0][0][0].setWeight(-0.5);
    network[0][0][1].setWeight(0.8);
    network[0][0][2].setWeight(0.6);

    network[0][1][0].setWeight(0.2);
    network[0][1][1].setWeight(0.9);
    network[0][1][2].setWeight(0.3);

    network[0][2][0].setWeight(-0.2);
    network[0][2][1].setWeight(-0.7);
    network[0][2][2].setWeight(0.8);

    network[0][3][0].setWeight(0.0);
    network[0][3][1].setWeight(0.4);
    network[0][3][2].setWeight(0.2);

    // layer 1 - 2
    network[1][0][0].setWeight(0.7);
    network[1][0][1].setWeight(0.3);
    network[1][0][2].setWeight(-0.2);

    network[1][1][0].setWeight(0.5);
    network[1][1][1].setWeight(-0.8);
    network[1][1][2].setWeight(-1.0);

    network[1][2][0].setWeight(0.7);
    network[1][2][1].setWeight(0.2);
    network[1][2][2].setWeight(0.7);

    network[1][3][0].setWeight(0.8);
    network[1][3][1].setWeight(-0.1);
    network[1][3][2].setWeight(0.9);

    auto output = network.feedForward({0.2, 0.7, 0.4});

    for (auto const &o : output)
        std::cout << o << ", ";

    std::cout << std::endl;

    return 0;
}


I could also post the "NeuralNetwork.h" and "NeuralNetwork.cpp" files, but they're a little long. Here are the files #included by "NeuralNetwork.h":

1
2
3
4
#include <stdexcept>
#include <vector>
#include <cmath>
#include <iostream> ///temp 


As I said earlier, I also tried running some HelloWorld programs. Here's one of them:

1
2
3
4
5
6
7
8
9
#include <iostream>

using namespace std;

int main()
{
    cout << "Hello world!!!" << endl;
    return 0;
}
Hmmm. So in other words, anything you compile as *.cpp compiles/links without errors, but won't run on Windows 8?

Did you try running an exe, for example a simple "Hello, World" as above compiled on Win 7, but on the Windows 8 machine? Not sure what we would learn from that, but just curious. Sounds wierd Kurtahn. Wish I could help, but I'm stumped.

The main experience I've had with this is that sometimes newer OSs are less 'forgiving' than older ones. When I moved from Win 2000 to XP I had a number of issues like that. When I tracked it down I always found errors in my code as the cause. The older OS was simply absorbing my abuse without complaint, whereas XP wouldn't have any of it.
As far as I know, CodeBlocks runs perfectly on Windows 8.1. I've never experienced such a problem.
I finally figured out what the issue was. A couple days ago, I found a couple old C++ programs that executed without any issue. I tried to find what they had in common, and I finally had a revelation and realized those projects were on my Avast scan exclusion list.

Normally, Avast scans newly created .exe's (apparently not ones written in C...) and lets me know about it. For some reason, though, Avast hasn't been able to scan any of my programs, and the programs would never run. I'm not really sure why I wasn't able to disable this feature by disabling Avast with the shields control feature. Anyway, as a temporary workaround, I just put all my project directories on the exclusion list.
Topic archived. No new replies allowed.