Convert a CPP file to an EXE

Author: Christy White
Date Of Creation: 4 May 2021
Update Date: 1 July 2024
Anonim
How to convert c++ file in windows aplication ( .exe ) file [EN]/[RO]
Video: How to convert c++ file in windows aplication ( .exe ) file [EN]/[RO]

Content

This tutorial gives you step-by-step instructions on how to convert C ++ source files to .exe files, which work on most (to avoid the word "all") Windows computers. Other extensions that work with this are .cpp, .cc and .cxx (and .c, to some extent, but don't assume it works). This guide assumes that the C ++ source code is for a console application and does not require external libraries.

To step

  1. First you need a C ++ compiler. One of the best compilers for Windows is the free Microsoft Visual C ++ 2012 Express.
  2. Start a new project in Visual C ++. This is quite easy. Click the "New Project" button in the top left corner and follow the steps to create a "Blank Project". Give it a name and click "Finish" in the next window.
  3. Copy and paste all .cpp files to the "Source Files" folder and copy all. h files (if any) to the "Header Files" folder. Rename the main .cpp file (the one with "int main ()") to the name of the project you chose. The external dependencies file will fill itself.
  4. Build and compile. Press the [F7] key when you are done with all of the above and the program will be created.
  5. Find the exe file. Navigate to the "Projects" file where Visual C ++ installs all programs (in Windows 7, this is the Documents folder). It will be in the file with the name you gave it earlier under the "Debug" directory.
  6. Test it. Double-click the .exe file to run it and if everything went well, the program should work fine. If it doesn't, try going through the steps again.
  7. If you want the program to run on another computer, the VC ++ Runtime Libraries must be installed on that computer. C ++ programs compiled with Visual Studio C ++ require these program libraries. You do not have to install it separately on your machine, because it is installed with Visual Studio, but you should not expect your customers to have it. Download link: http://www.microsoft.com/en-us/download/details.aspx?id=30679

Tips

  • Sometimes errors can be thrown because the original author used outdated methods or forgot to include the dependencies of the source code.
  • Make sure your Visual C ++ Express is up to date so that there are no errors during compile time.
  • In most cases, it is more efficient to let the creator of a program compile it for you. Only compile it yourself if there is absolutely no other option.

Warnings

  • STAY AWAY from Dev-C ++. It features an outdated compiler, has over 340 known bugs, and hasn't been updated in 5 years, leaving it in perpetual beta. If possible, use ANY OTHER COMPILER AND IDE EXCEPT Dev-C ++.
  • Since C ++ and C are very low-level programming languages, they have the potential to harm your computer. A quick check you can do is to check if the .cpp files have the line "#include WINDOWS.h" at the top. If so, DO NOT compile the program and ask the creator why they need access to the Windows API. If they can't answer this conclusively, ask an expert in a forum for help.

Necessities

  • A compiler (Visual C ++ is recommended)
  • A .cpp file or C / C ++ source code
  • A Windows computer (.exe is only supported by Windows)