Debugging callout library <DYNAMIC LIBRARY LOAD>

Primary tabs

Caché, Callout

I have a simple callout library:

#define ZF_DLL
#include 
#include 
#undef ERROR

int GetRandom(double* random) {
   // Py_Initialize();
   // Py_Finalize();
   *random = 1.0;
   return ZF_SUCCESS;
}

int main(int argc, char **argv)
{
   printf("Random: ");
   double random=0;
   GetRandom(&random);
   printf("%lf", random);
   return 0;
}

ZFBEGIN
    ZFENTRY("GetRandom","D",GetRandom)
ZFEND

I compile this code as a shared library and it works fine with:

set path = "library.dll"
write $ZF(-3, path, "GetRandom")

It also compiles and works as an executable.

However, when I uncomment these lines:

   Py_Initialize();
   Py_Finalize();

Shared library compiles, but I get <DYNAMIC LIBRARY LOAD> exception.
Executable version works without errors.

How can I debug this further?

Replies

when you get the error <DYNAMIC LIBRARY LOAD>, you should look at cconsole.log (or messages.log for IRIS), where you may find code of error.

It is possible that you build it for 32bit, but uses in 64bit instance.  In this case, you will get the error with code 139. if you got other code, you can google it.

when you get the error <DYNAMIC LIBRARY LOAD>, you should look at cconsole.log (or messages.log for IRIS), where you may find code of error.

Thank you. Got this error

Error loading dll (c:\users\eduard\eclipse-c-workspace\helloworld\debuglib\libhelloworld.dll) is 126

It is possible that you build it for 32bit, but uses in 64bit instance.  In this case, you will get the error with code 139. if you got other code, you can google it.

I can get it to work if I compile it without a few lines, so I'm sure it's 64bit.

well, error 126 is the dependency error. for such errors, I used Dependency Walker, very useful tool, for such cases.

As you said you managed to connect to this dll with less code, so, in added lines you use some external library, which can't be loaded. Just place missed dll's close to your, and it should work.

Thank you, Dmitry, I used Process Monitor to get relevant error:

Turns out dependent DLLs should be in bin folder or current folder, but not in callout library folder.