C++ Print listen

Questions regarding the DCMPRINT library, a DCMTK add-on that implements a DICOM Print Management SCP and SCU

Moderator: Moderator Team

Post Reply
Message
Author
ruben.cruz
Posts: 26
Joined: Fri, 2019-05-03, 15:06

C++ Print listen

#1 Post by ruben.cruz » Mon, 2020-03-30, 13:00

Hi,

after working with dcmtk we have been moving foward with dcmprint.

but this time after compiling with cmake we we start getting errors like:

Code: Select all

"mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in ..."
sp we complied again with

Code: Select all

DCMTK_OVERWRITE_WIN32_COMPILER_FLAGS  = FALSE

but now after compiling when we can any library like

Code: Select all

#include "dcmtk/dcmnet/dstorscp.h"
#include "dcmtk/dcmnet/dstorscu.h"
i get erros has

Code: Select all

'gethostname': redefinition; different linkage	hCarePrint	C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winsock2.h
Any ideia on what i may be doing wrong?

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1244
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

Re: C++ Print listen

#2 Post by Marco Eichelberg » Mon, 2020-05-04, 13:54

The problem here is that not all files in your project have been compiled with the same compiler options for the build model.
These options include /MT, /MD, /MTd, /MDd for "multithreaded", "multhreaded DLL", "multithreaded debug", "multhreaded DLL debug".
Microsoft provides four different versions of the C runtime (MSVCRT), one for each build model, so all files in one project must be compiled with the same model.

I am surprised that you got these warnings when including DCMPRINT, since this should be just one more module in DCMTK. Probably you can solve that by building DCMTK including DCMPRINT from scratch (or cleaning up the previous build).
In any case, you need to check the build model for your own project and make sure that DCMTK uses the same model.

In the current git version of DCMTK, the code that selects the build model when compiling DCMTK has been revised, and it might be worthwhile to try this if you are still struggling with this issue (i.e. use the latest version of DCMTK's "CMake" directory from the public git). In this latest version, you can explicitly select whether the /MT or /MD build model should be used (and, correspondingly, /MTd or /MDd for a Debug build).

ruben.cruz
Posts: 26
Joined: Fri, 2019-05-03, 15:06

Re: C++ Print listen

#3 Post by ruben.cruz » Tue, 2020-05-05, 10:47

Hi,

thank you for the answer we got this kind of running, but now we can't figure it out how to apply our configurations.
Sorry that this maybe could be easy to apply but we have been looking into this for a long time and we can't manage to find a solution.

So, we tried to make something basic, just to start a service to receive and then we want to print.
PSVTCPCentralServer* printserver = NULL;

OFConfigFile config(NULL, PSVConfig_MaxLevel, PSVConfig_CommentChar, OFTrue);

loadConfigFile(config, "C:\\Users\\User\\Desktop\\hCarePrint\\test\\tcpsrv.cfg");

printserver = new PSVTCPCentralServer(config, 3100);

long temp = printserver->getServerPort();

OFBool temp1 = printserver->statusOK();

printserver->mainLoop();
so, in our tcpsrv.cfg we should have most of the configurations needed, but we could not get any configuration running, thats why we apply the port (3100) later.
the loadConfigFile is just a function to open the file and then loadFile.

when we send a study to this service we got a lot of erros because presentation contexts and from what we can guess we are not using the config file correctly.

Any direction we should look??

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1244
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

Re: C++ Print listen

#4 Post by Marco Eichelberg » Tue, 2020-05-19, 18:24

I can only suggest that you look at the implementation of tcpsrv.cc, which is the main standalone print server.

One problem here is that you are using the PSVTCPCentralServer class. That is actually not a print server. When compiled on Unix/Linux, the print server uses one process only for inter-process communication (you can think of a whiteboard were messages are posted and picked up by other processes). That is what PSVTCPCentralServer implements.

You have to create three instances in order to get the print server running:
  • one instance of class PSVCentralClient (required by the constructor of class PSVPrinterBackEnd)
  • one instance of class PSVPrinterBackEnd (takes the config file object and the PSVCentralClient object as parameters)
  • one instance of class PSVPrintServer (several parameters, including the config file object, backend and PSVCentralClient instance)
The main loop of the print server should then look approximately like this:

Code: Select all

    long pid = 0;
    do {
      printserver.negotiateAssociation(OFFalse, pid); // accept incoming network connection (or timeout after 1 second)
      if (printserver.associationPresent()) do {
        printserver.messageLoop(); // process incoming message
      } while (printserver.associationPresent()); // as long as we're connected to the client
    } while (1); // repeat for next client

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest