How to run .exe files output by Turbo C++? - c++

I wrote a program in Turbo C++, and compiled it there. Everything was successful, and the program ran as expected. Now, I want to run the program as an exe file. I found the exe file in a separate folder named 'Source'. But whenever I try to run it, I get the error :"This app can't run on your PC. To find a version for your PC, check with the software publisher." None of the exe files in that folder are working, although all the other softwares (like Photoshop) are opening fine.
Could someone help me please?

The OS on your PC probably is 64 bit. So the older 16 bit application would not run on it. I suggest you to use some virtual machine with installed OS DOS (or free DOSBOX for example), or try to compile your program on more modern compiler.

write
system("PAUSE");
before return 0;

Related

Windows executable got executed on my linux

I wrote a simple code and compiled using g++ in linux in .exe format, suprisingly it got executed in my linux terminal. Can u say the reason for this ? Can linux terminal execute machine code in any format ? Can I run the same in windows ?
Code :
#include<iostream>
using namespace std;
int main(){
cout<<"Hello World !"<<endl;
return 0;
}
Compile code:
g++ main.cpp -o program.exe
OS: Linux Mint 20 Cinnamon.
I execute by typing ./program.exe
Q: I wrote a simple code and compiled using g++ in linux in .exe format, suprisingly it got executed in my linux terminal
A: There's nothing "surprising". I assume you compiled it under Linux? So why shouldn't you be able to run it under Unix?
Q: Will an .exe I build on Windows run on Linux (if I copied the binary)? A: Short answer: No.
Longer answer: you can install Wine to run Windows applications on Linux.
Q: Will an .exe I build on Ubuntu run on Windows? A: No.
Q: Does an executable I build on Ubuntu need to have the suffix .exe? A: No. File suffixes are irrelevant.
Q: Does an executable I build on Windows need to have the suffix .exe? A: Yes.
To answer your additional questions:
There are many reasons why an .exe built for one platform cannot load or run on a different platform.
Sam Varshavchik put it well:
It's for the same reason a radiator for your Toyota won't fit into a
Dodge
More to the point, an "executable image" is much more than just "the machine code".
An .exe is an example of "executable images". They come in many different formats: https://en.wikipedia.org/wiki/Category:Executable_file_formats. Most of these formats are platform-specific.
Any image must be loaded by the operating system in order to become a running process. This, too, is platform-specific.
The running process will need resources like file I/O , memory and shared libraries, which are also platform-specific.
I hope that helps...
Since you compiled the code using g++ on Linux, you should be able to run it on Linux but it won't work on Windows because the binary executable is compiled for Linux.
On Windows, .exe is the extension of the executable file but the binary code must be compiled for Windows so that it can run. On Linux, you can use any extension, .mp4 or anything and it will still run when typing ./program.mp4 in terminal.

Code::Blocks program doesn't run properly when run button is hit

I have been compiling and running programs in C++ on Code::Blocks longly but today one of my programs compiled successfully but when I ran the program it returned -12 with time -0.00s. Whenever I write a new program in C++ the program compiles but it doesn't run. Also when I open the executable file created by Code::Blocks in the same directory Windows takes permission from me to allow the executable file to make changes to the computer. I've been trying through the day but I couldn't figure out what could be going wrong.
Also when I tried uninstalling Code::Blocks it didn't uninstall completely and when I opened the Code::Blocks folder in Program Files and tried deleting the folder the folder MinGW couldn't be deleted because Access was denied.
Please help if you could comprehend the problem and have knowledge regarding the issue.

CPP file runs, but doesn't work when compiled to exe

I have created a cpp file using Microsoft Visual Studio 2010 and Allegro. It runs perfectly fine in the Visual Studio interface, but when I compile it into an exe, it says:
"The program can't start because allegro-5.0.10-monolith-md-debug.dll is missing from your computer. Try reinstalling the program to fix this problem."
I am running the exe on the same computer I used to write the code and debug it, so it shouldn't be the fault of a missing dll. Should it? That doesn't make sense to me.... I have compiled other exes before, and they do run on other computers, and the Allegro one works just fine while it's a cpp file, but when the Allegro file is run as an exe, it says I don't have the monolith thing.
Why is the file failing as an exe, but not a cpp?
This is what worked for me:
When in Configuration Properties -> Debugging
- Add PATH=c:\allegro\bin;%PATH% to the Environment Variable.
I had the exact same error, the program was telling me that it couldn't find the monolith DLL file. What I had noticed is instead of PATH=c:\allegro\bin;%PATH% I had put PATH=c:\allegro\bin:%PATH%. The difference is not easy to spot.
I put a : instead of a ; between bin and %PATH%
it was an easy mistake, however it caused me about 3 hours of heartache to fix.

c++ program failed to run on another pc with libgcc error

I wrote some simple code in C++, and I built it and ran it on my laptop, and everything as working. When I tried to run the .exe file on my brother's laptop, it gave me this error The program can't start because libgcc_s_sjlj-1.dll is missing from your computer. Try reinstalling the program to fix this problem. Am I missing something that I should have added or something?
Note: I don't know if it matters or not, but I'm using Code::Blocks.
Thanks
It matters because you used Code::Blocks. If you don't know about it, you most probably used Code::Blocks with MinGW. Install it on that machine followed by a reboot may fix it.
C++ programs need to have a runtime library -- you can think of it as needing .NET Framework to run C# or JRE to run Java programs. Visual C++ uses msvcrt (known as Visual C++ Runtime). Many installations of Windows seem to come with msvcrt by default which may explain why people using MSVC is less likely to run into issues like this.
If you statically link the CRT (C Run Time) you can lift the requirements of the clients having to have the DLL files installed, at the expense of having a larger .exe file.
A relevant SO answer: The program can't start because libgcc_s_dw2-1.dll is missing
You can place that DLL in the same folder as the .exe on your release and it should work

Program only executes if I run it in Visual Studio

I have been trying to find a solution for this problem but I haven't been able to see/find any answer that correctly solves it.
I coded a program (Qt + OpenCV) that works fine when I run it with Visual Studio, but trying to run the executable it simply does not execute anything. The program doesn't give any error: it just never starts.
I am not sure where to start checking what is happening and why it is not even starting (I could understand lack of libraries, some other error..).
I am basically interested on what are the best way of checking why a program runs when executed from the IDE and not from the executable created. As I said, I was expecting an error message if something was wrong. Any ideas? Any good programming advice regarding how to avoid this problem in the future?
Edit: I forgot to mention that I am coding with a Windows XP machine. It doesn't work in this machine when I try to execute the file. It executes normally on a W7 machine but not in other W7 machine.
The executable will need the QT libraries on the computer that you are running it on. On linux there is command (I think ldd) that will show you what libraries your executable needs. I am not sure about Windows but there should be something similar. At least on a linux computer it will not necessarily give you an error if the QT libraries are missing. The executable just seems to do nothing.
Try copying the executable into the same directory as the .dll files in the Qt 'bin' directory.
If that works then you just need to put the Qt bin directory into your path, or copy the dlls into the windows\system directory
You need not only the correct dlls in your path (best in the application directory), but also the plugins in the correct location. See my answer to the question: Qt dll deployment on windows.