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.
anyone help me: dcmtk3.6.3 cannot link the globals
Moderator: Moderator Team
-
- DCMTK Developer
- Posts: 2504
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: anyone help me: dcmtk3.6.3 cannot link the globals
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:
The "demo.cc" file in this example looks like this:
A pretty simple CMakeLists.txt file could be something like the following:
Code: Select all
# 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})
Code: Select all
#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;
}
Re: anyone help me: dcmtk3.6.3 cannot link the globals
I did not install. I just configured the correct directory for include and lib files.
Any difference?
Any difference?
-
- DCMTK Developer
- Posts: 2504
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: anyone help me: dcmtk3.6.3 cannot link the globals
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?
Who is online
Users browsing this forum: Ahrefs [Bot] and 1 guest