VS Express and Codeblocks created C++ programs will not work in Windows 7 64bit

So I have started to go back and re-learn how to code in C++, but I have very little programming experience outside of using c++ in college.

My problem is that I cannot get the simplest of programs to work on my windows 7 64 bit laptop. I have tried compiling and building in both code-blocks and VS Express and similar behaviour is experienced in both, except that VS Express will completely crash while code-blocks retains limited functionality.

I have access to a linux install and the code I use in a code-blocks install there works perfectly in it. So I am at a complete loss, because I am certain it is a windows problem, but I cannot find a solution to my problem.

What happens, in my windows machine, both in code-blocks and visual express when I build the program is: it will compile successfully.

However, when the program is run, two different console windows will open, the one which contains "hello" will open and say "hello", and then close. The other console window will remain open containing nothing and cannot be closed when it is created with VS Express. The name of the program remains running in the taskmgr and cannot be killed using taskmgr or even sysinternals processexplorer. VS Express crashes upon the close of the first window and I have to restart to try and begin again.

Codeblocks has similar behaviour, except when I use the "abort" button, the second console window containing nothing will then close. However, the program created "test1.exe" or whatever will still be running and similarly, in the case with the program created with VS Express cannot be closed or killed in any way.

I have no idea why any of this is happening with such basic code. I hope that someone here is able to help :P

Paulus

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

using namespace std;

int main()
{
    cout << "Hello world!" << endl;
    return 0;
}
You need to create a 32bit console application in Visual C++ basic copy and paste your code form the .txt file into it. The Visual C ++ software has links to videos on how to do this (usually just a matter of selecting 32bit console app template.

Once created it will run on all versions of Windows, once Microsoft Visual C++ 2008 (or later) Redistributable X86 and X64 is installed on the system you want to run it on.

Also make sure you have MinGW installed on the system your programming on and that you added it to a path in environment variables.

Also there is an option to compile a finished version of your code, make sure you select this.

Last edited on
Thank you CBasic. I checked my installs and I have everything you say. I also have followed those instructions to create the project as a 32bit console application as those were the instructions that are found on various tutorials.

I uninstalled VS Express 2012 and upgraded to 2013, and I used the same code. The behaviour changed somewhat, in that only one console window opens with my "hello world" phrase in it. The console window closes when I press enter, but then the VStudio crashes and when I check taskmgr the name of the program I created is running and cannot be killed.

I feel like there is something that I am missing. I keep my windows completely up to date, so I have no idea what the problem could be. All the various "solutions" I have found using google have not worked. My compilers are up to date, when I use codeblocks the program compiles and runs but then I cannot do anything further as the console application will not close.

All your help is appreciated.

Paulus
Topic archived. No new replies allowed.