DICOM @ OFFIS

Discussion Forum for OFFIS DICOM Tools - For registration, send email with desired user name to the OFFIS DICOM team
It is currently Fri, 2018-08-17, 08:15

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Fri, 2018-03-09, 19:23 
Offline

Joined: Fri, 2018-03-09, 08:47
Posts: 4
I am building dcmtk 3.6.3 using msvc2010 into a single dll and I used the lib to link to my program, and the globals defined in the library all reports unresolved external symbol. I checked both the dll and lib file using dumpbin tool and found that these globals are actually exported. The functions exported are fine to get linked.

Any help is appreciated. Thanks

This is dumpbin out on one variable from the dcmtk.lib file

?EC_Normal@@3UOFConditionConst@@B (struct OFConditionConst const EC_Normal)
This is dumpbin out on one variable from the dcmtk.dll file

6913 1B00 008F31A0 ?EC_Normal@@3UOFConditionConst@@B
This is the msvs2010 error:

error LNK2001: unresolved external symbol "struct OFConditionConst const EC_Normal" (?EC_Normal@@3UOFConditionConst@@B)
In the library, .h file is:

extern DCMTK_OFSTD_EXPORT const OFConditionConst EC_Normal;
#define makeOFConditionConst(name, module, code, status, text) \
const OFConditionConst name = { (module), (code), (status), (text) }
In the .cc file is:

makeOFConditionConst(EC_Normal, 0, 0, OF_ok, "Normal");

The MSVC2010 project is generated using cmake, /MD option is used since I need /MD option to work with my current applications.


Top
 Profile  
 
PostPosted: Mon, 2018-03-12, 20:10 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1963
Location: Oldenburg, Germany
How do you include the DCMTK into your program? Did you actually "INSTALL" the DCMTK after building it?

A pretty simple CMakeLists.txt file could be something like the following:
Code:
# DCMTK Demo Project

# declare project
PROJECT(DCMTK_DEMO)

# minimum CMake version required
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)

# specify DCMTK's (default) installation directory
SET(DCMTK_DIRECTORY "C:/Users/dicom/dcmtk-3.6.3-install" CACHE PATH "Directory where DCMTK library is installed.")

# approach #1: use FIND_PACKAGE() to search for installed DCMTK
#FIND_PACKAGE(DCMTK REQUIRED CONFIG PATHS ${DCMTK_DIRECTORY} NO_DEFAULT_PATH)

# approach #2: include DCMTK's CMake configuration directly
INCLUDE(${DCMTK_DIRECTORY}/cmake/DCMTKConfig.cmake)

# declare include directories
INCLUDE_DIRECTORIES(${DCMTK_INCLUDE_DIRS})

# declare executable and link required libraries
ADD_EXECUTABLE(demo demo.cc)
TARGET_LINK_LIBRARIES(demo ${DCMTK_LIBRARIES})


The "demo.cc" file in this example looks like this:
Code:
#include "dcmtk/config/osconfig.h"
#include "dcmtk/dcmdata/dctk.h"

int main(int argc, char* argv[])
{
    /* iterate over all command line parameters */
    for (int i = 1; i < argc; i++)
    {
      /* load the specified DICOM file */
      DcmFileFormat dicomFile;
      if (dicomFile.loadFile(argv[i]).good())
      {
         /* and dump its content to the console */
         COUT << "DICOM file: " << argv[i] << OFendl;
         dicomFile.print(COUT);
         COUT << OFendl;
      }
    }

    return 0;
}


Top
 Profile  
 
PostPosted: Mon, 2018-03-12, 22:22 
Offline

Joined: Fri, 2018-03-09, 08:47
Posts: 4
I did not install. I just configured the correct directory for include and lib files.
Any difference?


Top
 Profile  
 
PostPosted: Tue, 2018-03-13, 09:59 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1963
Location: Oldenburg, Germany
It shouldn't make any difference; but I always use the installed version of the DCMTK, so I am not 100% sure. Do you use the exported CMake configuration as described in the above example?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group