Try exporting with /MT enabled.
triumphost
Practically a Master Poster
625 posts since Oct 2009
Reputation Points: 59
Solved Threads: 55
Skill Endorsements: 1
The solution to your problem is to use dynamic loading of the DLL. Look at the functions: LoadLibrary(), GetProcAddress(), and FreeLibrary(). This is basically the way that you can programmatically call a function (LoadLibrary) to load the DLL, then make calls to the GetProcAddress function to obtain function pointers to individual functions within the DLL, and then, once you are completely finished using the DLL, you can call FreeLibrary to un-load the DLL. This is, of course, a lot more trouble than doing it statically (the traditional way, where it gets loaded before you even start the main() function) because you have to manually assign all the function pointers via calls to GetProcAddress.
Another solution is to create a module of your own (a DLL) that has all the code that uses that DLL, but exposes fewer functions. Then, that new module would load the DLL in question statically (as usual), but be loaded dynamically by your main application. This way, you avoid having to dynamically load the external DLL, if that DLL has a lot of functions to be loaded from it, and you can still catch the error about the missing DLL.
N.B.: Under Unix/Linux/MacOSX systems, the equivalent functions to LoadLibrary / GetProcAddress / FreeLibrary are dlopen() / dlsym() / dlclose(), respectively.
Can you please explain what is /MT and how to enabled it ?
The /MT is a command-line option for the MSVC (microsoft visual C++) compiler that tells it to load the DLL under the same memory management (heap) as the main application. This is only valid if both the DLL and main application were compiled with the same compiler, same compiler version and same options. It has absolutely nothing to do with the question you asked. And in fact, it had no effect when doing dynamic loading as I suggested above.
mike_2000_17
21st Century Viking
3,144 posts since Jul 2010
Reputation Points: 2,062
Solved Threads: 626
Skill Endorsements: 41
I was going to suggest the same thing that mike_2000_17 did - build the system so it doesn't require the dll to get into main, and then dynamically load (link) it. This approach has worked well for me in the past, plus you can add functionality that way without rewriting/compiling/linking your code.
rubberman
Posting Maven
2,581 posts since Mar 2010
Reputation Points: 365
Solved Threads: 308
Skill Endorsements: 52