0

I wrote a c++ program and converted it to a .exe file with the hopes to let it run on windows without needing to install a compiler. I ran well on my main computer (which has a compiler so it ran as expected) but did not run on another device. The error message shown was "libgcc_s_dw2-1.dll was not found"

How can I run a c++ program (or .exe file) from a flashdrive or other medium on any windows machine without extra installation.

jrima12
  • 50
  • 8
  • 6
    Maybe you need the correct linkage when compiling. See this answer: https://stackoverflow.com/questions/4702732/the-program-cant-start-because-libgcc-s-dw2-1-dll-is-missing. Maybe: g++ my.cpp -o my.exe -static-libgcc – Omid CompSCI Jul 11 '20 at 02:56
  • You need to ship your compilers runtime libraries along with your executable. Or statically link it. – Jesper Juhl Jul 11 '20 at 03:27
  • 2
    Does this answer your question? [The program can't start because libgcc\_s\_dw2-1.dll is missing](https://stackoverflow.com/questions/4702732/the-program-cant-start-because-libgcc-s-dw2-1-dll-is-missing) – Omid Jul 11 '20 at 04:01

1 Answers1

1

C++ programs require additional c++ standard and runtime libraries to run. Most linker links to these libraries dynamically. That is some dll are required for running the program. You can run the program from a portable flash drive by copying those dll to the same folder as the application.

Alternatively, some linkers also have option to statically link, that is incorporate the code in dll ( kind of ) to your binary exe.

So you can either find out what all dll is required and copy them to your local folder ( maybe use something like dependancy walker or this newer one, i haven't actually used the newer alternative). Or use static linking like shown in this answer.

WARhead
  • 643
  • 5
  • 17