Jump to content
  • Advertisement
Sign in to follow this  
chazzz

Console App won't run on other computers

This topic is 3557 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I just began learning Cpp tonight and I came across a problem that probably/hopefully is basic enough but that I haven't been able to solve myself, despite googling the issue for over an hour now. I've downloaded Visual Cpp 2008 Express and made quite a simple application;
#include "stdafx.h"
#include <iostream>
#include <windows.h>

using namespace std;


int main()
{
	int min=0, max=0, i=0;

	cout << "Please input a minimum number:" << endl;
	cin >> min;
	cout << "Please input a maximum number:" << endl;
	cin >> max;

	for(i=min; i <= max; i++)
	{
		cout << i << endl;
		Sleep(30);
	}
	return 0;
}
I then build/compile this under 'Release' and sent the .exe file to my friend over MSN; he can't run the program. I've tried re-building, doing another simple program, sending him the debug .exe fil etc etc.. nothing works. I then proceeded to google this issue for a very long time and I can't find any answer at all. It almost hurts to ask, since I believe it's surely a rookie mistake, but if I can't get even a simple Console Application to run on someone elses computer; my game developement dreams are a joke to say the least.

Share this post


Link to post
Share on other sites
Advertisement
The person running your application needs the Visual C++ Runtime installed in order to run your application. It works fine on your machine because Visual Studio 2008 automatically installed it for you.

Share this post


Link to post
Share on other sites
Billr17: So I have to ask everyone who I want to send my future applications to, to install that?
I'm thinking a installer will probably be the solution for more advanced applications? But what about text-based console app games etc?

daviangel: I did. Maybe it's just me but I never found a solution.
I found some tips and I've tried them (changing something in the project properties etc) but none worked.

Share this post


Link to post
Share on other sites
Quote:
Original post by chazzz
Billr17: So I have to ask everyone who I want to send my future applications to, to install that?
I'm thinking a installer will probably be the solution for more advanced applications? But what about text-based console app games etc?


You actually have two options. Right now your program is (probably) linked against the DLL versions of the CRT. That is the reason the runtime needs installed for your application can run. Alternatively, you can also statically link against the CRT. This will cause the CRT to be built into your application. Hence, the person running your program will no longer need to install the CRT.

If you statically link against the CRT, it will make your exe much larger. Additionally, your application will not be able to benefit from patches to the CRT DLL's. Because of this, it is generally best to dynamically link against them.

To statically link against the runtime, do the following.
1.) Right click on your C++ project.
2.) Select the 'Properties' menu item.
3.) Goto Configuration Properties -> C/C++ -> Code Generation
4.) Locate the 'Run Time Library' option.
5.) Set the option to /MT for your release build and /MTd for your debug build.

To read more about these options and the CRT, see C Run-Time Libraries.




Share this post


Link to post
Share on other sites
Quote:
Original post by chazzz
Billr17: So I have to ask everyone who I want to send my future applications to, to install that?
I'm thinking a installer will probably be the solution for more advanced applications? But what about text-based console app games etc?

daviangel: I did. Maybe it's just me but I never found a solution.
I found some tips and I've tried them (changing something in the project properties etc) but none worked.

Well I was thinking exactly what Billr17 so kindly posted already. Main problem is that you will need to figure out how to redistribute the c++ runtimes with your app so it will correctly run on non developer computer.

Share this post


Link to post
Share on other sites
You could also use a different IDE, such as code::blocks. That will make universal .exes (assuming I know what I'm talking about...it worked in the past)

Share this post


Link to post
Share on other sites
Quote:
Original post by DOS4dinner
You could also use a different IDE, such as code::blocks. That will make universal .exes (assuming I know what I'm talking about...it worked in the past)

Yeah, but then you get those "Why is my helloworld.exe 500kb large?" threads regularly ;)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!