Hello everyone,

i have the following code

#include <iostream>
#include <conio.h> 
using namespace std;

int main()
{
	cout<<"\nPress Any Key To Continue ";
	getch();
	return 0;
}

it compiles fine on my windows xp using microsoft visual c++ , and i can run the resultant executable file with no problems at all , but when i copy that executable file to another computer and try to run it i get an error that says "application failed to start because application configuration is incorrect".

help please.

Member Avatar for iamthwee

What Operating System does you other computer have?

What happens if you take out the conio header and change it to:-

#include <iostream>
using namespace std;

int main()
{
  cin.get();
  return 0;
}

What Operating System does you other computer have?

What happens if you take out the conio header and change it to:-

#include <iostream>
using namespace std;

int main()
{
  cin.get();
  return 0;
}

the other computer's OS is the same and i must use getch()

Member Avatar for iamthwee

The other things I can think of is that you might be using the dubug exe, as opposed to the release exe.

All program examples in [...] are built in Debug mode. To create a Release Mode version we have to change the Visual C++ project to a Release Mode. After rebuilding the program, the executable should be portable on Windows machine.

The other things I can think of is that you might be using the dubug exe, as opposed to the release exe.

indeed i was building in debug mode , i changed that and built in release mode but that didn't change anything and i still got the error

Member Avatar for iamthwee

What version of studio is it?

Make sure it doens't need the dotnet framework. I have never used visual c++ so I don't know.

This is why I like dev-cpp.
http://www.bloodshed.net/devcpp.html

I have no problems, and the exe generated is good to go on any windows machine.

> but when i copy that executable file to another computer and try to run it i get an error
> that says "application failed to start because application configuration is incorrect".

you also need to copy the manifest file created when linking the application. (the manifest file contains information about the application's dependencies such as the runtime libraries.) the manifest file needs to be copied into the same location as the executable image (.exe).

> but when i copy that executable file to another computer and try to run it i get an error
> that says "application failed to start because application configuration is incorrect".

you also need to copy the manifest file created when linking the application. (the manifest file contains information about the application's dependencies such as the runtime libraries.) the manifest file needs to be copied into the same location as the executable image (.exe).

i copied a file with the extension "manifest" , but it didn't help , in my code , if i don't include "conio.h" , i stop getting the error , so the "conio" header file is causing this ?

Member Avatar for iamthwee

Are you saying the program works ok on the different system when you take out the conio.h and include the manifest file?

Are you saying the program works ok on the different system when you take out the conio.h and include the manifest file?

when i take out the conio.h , it works without copying the manifest file but even when i had conio.h included , the manifest file didnt help

What version of studio is it?

Make sure it doens't need the dotnet framework. I have never used visual c++ so I don't know.

This is why I like dev-cpp.
http://www.bloodshed.net/devcpp.html

I have no problems, and the exe generated is good to go on any windows machine.

i compiled the same code with dev-c++ and the exe file worked without giving me that error, but i still need to find out why its not working when compiled in visual c++ 2005 express edition

presumably, you are using vc++ 8.0 (2005).
the VC80 run-time library is a side-by-side execution (SxS) assembly. VC 2005creates a manifest for the program, and set it to depend on VC80 CRT. In order for the application to run, you need the VC80 CRT to be on the target machine.
the error mesage that you saw ( 'application configuration is incorrect' ) is because of the Win32 error SXS_CANT_GEN_ACTCTX. cmd.exe does not understand this error, so it emits a generic error message.

You need to first copy VC80 CRT DLL into your application local folder ( in addition to the manifest). then copy x86_*_Microsoft.VC80.CRT*.manifest (from windows\winsxs\manifests folder) to Microsoft.VC80.CRT.manifest in your application local folder.

note: compile the application in release mode; only retail VC80 CRT is redistributable.

for more information, http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=72965&SiteID=1

(guess) looks like the conio.h functions are only in the CRT dll.

presumably, you are using vc++ 8.0 (2005).
the VC80 run-time library is a side-by-side execution (SxS) assembly. VC 2005creates a manifest for the program, and set it to depend on VC80 CRT. In order for the application to run, you need the VC80 CRT to be on the target machine.
the error mesage that you saw ( 'application configuration is incorrect' ) is because of the Win32 error SXS_CANT_GEN_ACTCTX. cmd.exe does not understand this error, so it emits a generic error message.

You need to first copy VC80 CRT DLL into your application local folder ( in addition to the manifest). then copy x86_*_Microsoft.VC80.CRT*.manifest (from windows\winsxs\manifests folder) to Microsoft.VC80.CRT.manifest in your application local folder.

note: compile the application in release mode; only retail VC80 CRT is redistributable.

for more information, http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=72965&SiteID=1

(guess) looks like the conio.h functions are only in the CRT dll.

i compiled it with dev-c++ and the resulting exe file worked on the other machine

> i compiled it with dev-c++
well, you really compiled with g++.
> and the resulting exe file worked on the other machine
yes it would; g++ has no issues with SxS. infact g++ does not know about SxS.

that aside, the real issue is that functions in conio.h is not part of the C programming language, the standard C library, ISO C++, the win32 api or POSIX. implementations which do provide the header implement them in whatever way they deem fit. there are no standards; either de jure or de facto. if you decide to use them in your programs, you alone are responsible for the consequences.

Member Avatar for iamthwee

The real question is why do you need getch(). As Vj mentioned you should not be using it because it is non-standard.

To me, the only justification of its use is for a password masking program. I hope you are not using it to pause the program, if you are then post your code and we can show you an alternative way, perhaps using cin.get().

well actually i am using it for password input

Member Avatar for iamthwee

well actually i am using it for password input

I can only assume vs 2005 is complaining about the conio.h . Dev-cpp doesn't seem to have this problem.

The only other thing I can think of is using a winAPI function to get around this. Perhaps...
http://cboard.cprogramming.com/showthread.php?t=95195&highlight=password

Although I've not tested it, and maybe you might even need to download the sdk since you are using the express version of studio to get it to work? Again this is why I don't use it. Ha ha.


You may want to look at my attempts for completeness (see last two posts)
http://www.daniweb.com/forums/thread77633.html

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.