Compiling code to executable file

Hi all,

Just starting out with C++ again after a long break since Uni. I have some experience in other languages but am still a very much a beginner with C++.

I am trying to understand how I might create a program in C++ and have it run as an .exe file on other computers.

I have seen other posts stating that Code Blocks leaves a .exe file in the save directory, which it does, however when opening this .exe I get error messages stating that .dll files are missing. (libgcc_s_dwl2-1.dll, libstdc++-6.dll)

I get similar errors when trying to execute on a different Windows machine. I have a stand alone program in mind I wish to create but I will want it to be able to run on any windows machine without having to install anything additional.

please can someone tell me where I am going wrong.

Thanks in advance.

Adam
Your version of MinGW does not statically link its runtime by default.
You'll find those DLLs in the /bin folder of wherever g++.exe is installed. You can copy them to the destination machine.

If you don't wish for the user of your program to have those DLLs, you can add the following compiler flags:
-static -static-libgcc -static-libstdc++
Last edited on
Hi Ganado,

Thanks that did the trick!!

For those reading this thread I was unsure how to add these flags in code blocks, this is the way I did it in the end.

on the menu bar, go to Project >> Build Options >> Compiler Settings -- Check the boxes next to the compiler flags listed above by Ganado.

Thanks for the help!

Topic archived. No new replies allowed.