Passing instances to shared library problem

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Posts: 329
Joined: Mon, 2009-02-23, 19:57

Passing instances to shared library problem

#1 Post by martinrame » Mon, 2011-08-15, 02:38

Hi, I'm trying to pass a DcmFileFormat instance to a shared library, to change some of it's tag values.

If I call saveFile before dlclose, the file is changed as expected, but if I call saveFile *after* dlclose, the file is not changed.

This is part of a bigger program, and I need to call dlclose before saving the file.

Here's the caller of the shared library:

Code: Select all

    void* lhandle = dlopen("./", RTLD_NOW);

    if (lhandle) {
      typedef void (*processDataset)(DcmFileFormat *);
      processDataset lprocessDset = (processDataset) dlsym(lhandle, "processDataset");
      if (!lprocessDset) {
         DCMQRDB_INFO("Cannot load symbol 'processDataset': " << dlerror());

And here's the important part of the library:

Code: Select all

extern "C" {
  void processDataset(DcmFileFormat * ff)
    OFString lPatientName;
    DcmDataset * dataset = ff->getDataset();
    dataset->putAndInsertOFStringArray(DCM_PatientsName, "NEW VALUE");
What I'm doing wrong?.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest