user451498
user451498

Reputation:

Getting a program only to run with certain dlls in the directory

When, for instance, I create a program and compile it with MinGW if I delete the environment variable I need to put the dll in the directory for it to work

ie. libgcc_s_dw2-1.dll

without it the program will not even start.

When developing with QT I noticed I needed another dll in the directory, it was QtCored4.dll, I was wondering how the program knows that the dll is missing?

Also is there anyway to add something like this to a program, like a define statement or something?

I need an answer that can work with C++ :)

Upvotes: 0

Views: 66

Answers (2)

ta.speot.is
ta.speot.is

Reputation: 27214

when developing with QT I noticed I needed another dll in the directory, it was QtCored4.dll, I was wondering how the program knows that the dll is missing

You can also try to load the DLL yourself at runtime, and handle failure gracefully. See LoadLibrary and GetProcAddress.

Upvotes: 1

casablanca
casablanca

Reputation: 70721

That is taken care by the operating system -- since your program uses functions from the DLL, it is automatically loaded when your program starts, and if the DLL is missing, you will get an error. You can read more about this process on MSDN: Load-Time Dynamic Linking.

Upvotes: 1

Related Questions