I compiled (on Windows 10, using MinGW) a Dynamic Link Library that implements an interface to another one. I then use
LibraryLoad[dependencyDLL] and then
LibraryFunctionLoad[interfaceDLL,...] to expose a function to the Mathematica Kernel. When I try to use that function the Kernel crashes. That makes me suspect that the Wolfram Kernel cannot find the dependency DLL (which is not in my %PATH%).
I have no doubt that my interface is correct as everything above worked as intended on a Linux machine. I can confirm that my Windows compilation is correct as the test program (written in C) ran correctly.
How can I test if the Wolfram Kernel can see and load the dependencyDLL?
FindLibrary[dependencyDLL] outputs a path to the DLL. So Wolfram can see the library (if not, that would output a
$Failed). Maybe its the interfaceDLL that cannot see its dependency?
Edit: further info
I could make it work on a Mac. Putting the dependency DLL on my PATH did not solve the problem (on Windows). I suspect it is something related to linking and other dependencies that I am unaware of (my dependecy DLL is provided by third parties).
I tried to build a minimal working example where I would reproduce that behavior. I could not...
The question remains: how can I see if the Kernel is crashing with a message of undefined reference or similar?
Edit: further info 2
The third party DLLs I am trying to use are intel's MKL. It seems that Mathematica has its own internal version of the MKL, thats why it did not crash on Linux and MacOS; but somehow the windows version is failing.
As per a comment: Using the Visual Studio compiler would be too much trouble as it does not comply to the C99 Standard, in which my code is based a lot (specially complex.h). I have no guarantee that these DLL are compatible with MinGW (gcc on Windows), but all pure C programs I've run so far on Windows did it without crashes. That's why I suspect it is a Mathematica side problem.