1

I'm just starting to learn c++ using the CodeLite IDE. Everything is working fine, however I ran into a problem where the program compiles, but exits immediately. I was able to fix it by copying the libstdc++-6.dll file from MinGW into the same folder as the program exe. Although I don't mind doing this, I'm wondering if there's a way I can make CodeLite include this file automatically with every project.

Evan Wild
  • 67
  • 5
  • 1
    ***I can make CodeLite include this file automatically with every project.*** Make sure that this `.dll` is in one of the folders in your windows `PATH` environment variable. You can just add an additional path in the windows GUI. https://www.architectryan.com/2018/03/17/add-to-the-path-on-windows-10/ – drescherjm Dec 25 '18 at 02:16

1 Answers1

3

Your program crashes because the program cannot find a dependency it needs (in this case it was libstdc++). For some background, you can have 2 types of dependencies: static and dynamic. Static dependencies are built into your program. Dynamic dependencies rely on being loaded at runtime (Windows calls these DLLs).

As drescherjm mentioned in the comments, operating systems use path variables for storing dependencies, command line program paths, and other information. Simply go into your Windows search button, and write in "Environment variables", and then click on "Path" under "System variables" (to make the dll accessible system wide) or "User variables" (to make the dll accessible only for your account). Then you can either add a new folder path, or you can copy it to an existing one. Note that Windows will also search the same directory as the executable (which is why copying the DLL worked).

Note that if you ever distribute your program online, you also need to make sure the user has those dynamic dependencies. You can either include the DLLs in a bundle (watch out for licensing), or tell them where they can find it.

Jas
  • 850
  • 7
  • 21