Hi,

I sent an e-mail (subject: "problem with running C++ OpenDX loadable
modules on AIX") to this mailing list a few hours ago, but forgot to
send the source code which I mentioned in the previous e-mail.  The
file is below.

Sorry for the problem.


Best,
Irek

Software Developer
Center for Integrated Plasma Studies
University of Colorado


**************************************************************************

The source code of the test program:

#include <stdio.h>
#include <dlfcn.h>
#include <dx/dx.h>
#include <sys/ldr.h>

Object in[6];
Object out;

Error DXAddModule (char *name, ...)
{
  printf("Module %s has registered itself.\n", name);

  return OK;
}

void error(char *info)
{
  char buffer[1024];

  printf("*** EXITING ***\n");
  loadquery(L_GETINFO, buffer, 1024);
  printf("INFO=%s\n", buffer);

  loadquery(L_GETMESSAGES, buffer, 1024);
  printf("MESSAGES=%s\n", buffer);

  loadquery(L_GETLIBPATH, buffer, 1024);
  printf("LIBPATH=%s\n", buffer);

  printf("%s\nInfo: %s\n", dlerror(), info);
  exit(1);
}

int main(void)
{
  void *handle;
  void *func;

  in[0] = (Object) DXMakeString("./ImportHDF5FieldUsage.h5");
  in[5] = (Object) DXMakeInteger(1);

  handle = dlopen("./ImportHDF5Field", RTLD_LAZY | RTLD_GLOBAL);

  if (!handle)
    error("after dlopen");

  printf("Trying to get a function...\n");

  func = dlsym(handle, "m_ImportHDF5Field");

  if (!func)
    error("after dlsym");

  printf("Got a function...\n");

  ((Error (*)(Object *, Object *))func)(in, &out);

  dlclose(handle);
}



Reply via email to