0

I made a little text adventure game in Code::Blocks that just consists of the libraries iostream and string. When I compiled and ran it worked perfectly in the program but when I try to execute the .exe file itself I get an error that is displayed in the following image

http://i1273.photobucket.com/albums/y414/blueblur112198/error_zps558a6867.png

I did a bunch of google searching for answers but none of them worked. I also searched this site and none of the answers here worked. So I decided to make an account here and ask for my specific problem.

My compiler is GNU GCC and my developing platform is Windows 7 64 bit.

1 Answers1

0

Since you're using both iostream and string, the executable needs to link against the standard library, which contains the definitions of, say, string::begin() and string::size().

If the standard library was built as a shared library (i.e. a DLL if you're under Windows), then it needs to be located in order for the program to run correctly. The reason you can execute it inside of Code::Blocks is that the IDE is surely including the library's path in the list of directories to look for dynamic objects, but whenever you run the executable by itself the system cannot find the DLL.

The solution is to either include libgcc_s_dw2-1.dll in your executable's folder (tedious) or add the path it is located at to the PATH environment variable.

  • How would one go about doing that? I am a bit new to this language. –  Mar 12 '14 at 18:41
  • @Blueblur The first option simply requires you to go to the `bin` directory within the compiler's distribution, grab the DLL and paste it in the directory the executable is located at. The second one involves setting an environment variable, take a look at [this](http://stackoverflow.com/questions/9546324/adding-directory-to-path-environment-variable-in-windows). –  Mar 12 '14 at 18:49