errors in linking dcmtk libraries!

Compilation and installation of DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
sivasankari
Posts: 20
Joined: Thu, 2005-03-10, 11:28
Location: India
Contact:

errors in linking dcmtk libraries!

#1 Post by sivasankari »

hello everybody, i try to link dcmtk with my code(DicomData) .
My CmakeLists.txt looks like this.
# declare project
PROJECT(DAL_Tests)
ADD_DEFINITIONS(-DHAVE_STD_NAMESPACE)
ADD_DEFINITIONS(-DHAVE_STRSTREAM_H)
ADD_DEFINITIONS(-DHAVE_CLASS_TEMPLATE)
ADD_DEFINITIONS(-DHAVE_FUNCTION_TEMPLATE)
ADD_DEFINITIONS(-D_REENTRANT)

# declare include directories which hold for all subdirectories
INCLUDE_DIRECTORIES(include

/home/shankari/DAL_Lib/DAL_Lib/dcmtk/dcmdata/include
/home/shankari/DAL_Lib/DAL_Lib/dcmtk/dcmimage/include
/home/shankari/DAL_Lib/DAL_Lib/dcmtk/dcmstat/include
/home/shankari/DAL_Lib/DAL_Lib/dcmtk/dcmsr/include
/home/shankari/DAL_Lib/DAL_Lib/dcmtk/ofstd/include
/home/shankari/DAL_Lib/DAL_Lib/dcmtk/dcmwlm/include
/home/shankari/DAL_Lib/DAL_Lib/dcmtk/dcmimgle/include
/home/shankari/DAL_Lib/DAL_Lib/dcmtk/dcmjpeg/include
/home/shankari/DAL_Lib/DAL_Lib/dcmtk/dcmnet/include
/home/shankari/DAL_Lib/DAL_Lib/dcmtk/dcmtls/include
/home/shankari/DAL_Lib/DAL_Lib/dcmtk/dcmsign/include
/home/shankari/DAL_Lib/DAL_Lib/dcmtk/imagectn/include
/home/shankari/DAL_Lib/DAL_Lib/dcmtk/config/include
/home/shankari/DAL_Lib/DAL_Lib/dcmtk/dcmjpeg/libijg12/include
/home/shankari/DAL_Lib/DAL_Lib/dcmtk/dcmjpeg/libijg16/include
/home/shankari/DAL_Lib/DAL_Lib/dcmtk/dcmjpeg/libijg8/include
)
LINK_DIRECTORIES(lib /home/shankari/DAL_Lib/DAL_Lib)
#executable
ADD_EXECUTABLE(DAL_Tests DAL2.0Tests DcmFileTest DcmDirTest DcmServicesTest DcmItemTest)

TARGET_LINK_LIBRARIES(DAL_Tests cppunit dal_lib dcmdata dcmimage imagedb dcmpstat dcmdsig dcmsr ofstd dcmwlm dcmimgle dcmjpeg dcmnet dcmtls ijg12 ijg16 ijg8 z)

i am getting the following errors when i compile with cmake.

Building executable /home/shankari/DAL_Lib/DAL_Lib/DALTests/DAL_Tests...
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x1cc3): In function `CDicomData::ST_GetBlockValue(int, long, bool (*)(int, unsigned long, int, unsigned char*, int, int))':
: undefined reference to `DJDecoderRegistration::registerCodecs(E_DecompressionColorSpaceConversion, E_UIDCreation, E_PlanarConfiguration, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x2192): In function `CDicomData::ST_GetBlockValue(int, long, bool (*)(int, unsigned long, int, unsigned char*, int, int))':
: undefined reference to `DcmItem::findAndGetUint16(DcmTagKey const&, unsigned short&, unsigned long, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x21de): In function `CDicomData::ST_GetBlockValue(int, long, bool (*)(int, unsigned long, int, unsigned char*, int, int))':
: undefined reference to `DcmItem::findAndGetUint16(DcmTagKey const&, unsigned short&, unsigned long, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x222a): In function `CDicomData::ST_GetBlockValue(int, long, bool (*)(int, unsigned long, int, unsigned char*, int, int))':
: undefined reference to `DcmItem::findAndGetUint16(DcmTagKey const&, unsigned short&, unsigned long, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x2279): In function `CDicomData::ST_GetBlockValue(int, long, bool (*)(int, unsigned long, int, unsigned char*, int, int))':
: undefined reference to `DcmItem::findAndGetUint16(DcmTagKey const&, unsigned short&, unsigned long, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x22c8): In function `CDicomData::ST_GetBlockValue(int, long, bool (*)(int, unsigned long, int, unsigned char*, int, int))':
: undefined reference to `DcmItem::findAndGetUint16(DcmTagKey const&, unsigned short&, unsigned long, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x2314): In function `CDicomData::ST_GetBlockValue(int, long, bool (*)(int, unsigned long, int, unsigned char*, int, int))':
: undefined reference to `DcmItem::findAndGetSint32(DcmTagKey const&, long&, unsigned long, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x2386): In function `CDicomData::ST_GetBlockValue(int, long, bool (*)(int, unsigned long, int, unsigned char*, int, int))':
: undefined reference to `DcmItem::putAndInsertString(DcmTag const&, char const*, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x2437): In function `CDicomData::ST_GetBlockValue(int, long, bool (*)(int, unsigned long, int, unsigned char*, int, int))':
: undefined reference to `DcmItem::putAndInsertUint16(DcmTag const&, unsigned short, unsigned long, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x24eb): In function `CDicomData::ST_GetBlockValue(int, long, bool (*)(int, unsigned long, int, unsigned char*, int, int))':
: undefined reference to `DcmItem::putAndInsertUint16(DcmTag const&, unsigned short, unsigned long, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x259f): In function `CDicomData::ST_GetBlockValue(int, long, bool (*)(int, unsigned long, int, unsigned char*, int, int))':
: undefined reference to `DcmItem::putAndInsertUint16(DcmTag const&, unsigned short, unsigned long, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x2656): In function `CDicomData::ST_GetBlockValue(int, long, bool (*)(int, unsigned long, int, unsigned char*, int, int))':
: undefined reference to `DcmItem::putAndInsertUint16(DcmTag const&, unsigned short, unsigned long, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x270d): In function `CDicomData::ST_GetBlockValue(int, long, bool (*)(int, unsigned long, int, unsigned char*, int, int))':
: undefined reference to `DcmItem::putAndInsertUint16(DcmTag const&, unsigned short, unsigned long, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x27c1): more undefined references to `DcmItem::putAndInsertUint16(DcmTag const&, unsigned short, unsigned long, int)' follow
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x30e7): In function `CDicomData::ST_SetValueString(int, long, char*)':
: undefined reference to `DcmItem::putAndInsertString(DcmTag const&, char const*, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x31a7): In function `CDicomData::ST_SetNextValueString(int,long, char*)':
: undefined reference to `DcmItem::putAndInsertString(DcmTag const&, char const*, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x3269): In function `CDicomData::ST_SetValueInt(int, long, int)':
: undefined reference to `DcmItem::putAndInsertSint32(DcmTag const&, long, unsigned long, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x332b): In function `CDicomData::ST_SetNextValueInt(int, long, int)':
: undefined reference to `DcmItem::putAndInsertSint32(DcmTag const&, long, unsigned long, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x33ed): In function `CDicomData::ST_SetValueUnsignedInt(int, long, unsigned int)':
: undefined reference to `DcmItem::putAndInsertUint32(DcmTag const&, unsigned long, unsigned long, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x34af): In function `CDicomData::ST_SetNextValueUnsignedInt(int, long, unsigned int)':
: undefined reference to `DcmItem::putAndInsertUint32(DcmTag const&, unsigned long, unsigned long, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x357a): In function `CDicomData::ST_SetValueShort(int, long, short)':
: undefined reference to `DcmItem::putAndInsertSint16(DcmTag const&, short, unsigned long, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x3644): In function `CDicomData::ST_SetNextValueShort(int, long, short)':
: undefined reference to `DcmItem::putAndInsertSint16(DcmTag const&, short, unsigned long, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x370e): In function `CDicomData::ST_SetValueUnsignedShort(int, long, unsigned short)':
: undefined reference to `DcmItem::putAndInsertUint16(DcmTag const&, unsigned short, unsigned long, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x37d8): In function `CDicomData::ST_SetNextValueUnsignedShort(int, long, unsigned short)':
: undefined reference to `DcmItem::putAndInsertUint16(DcmTag const&, unsigned short, unsigned long, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x38cb): In function `CDicomData::ST_SetBlockValue(int, long, char*, unsigned long, bool*)':
: undefined reference to `DcmItem::putAndInsertUint8Array(DcmTag const&, unsigned char const*, unsigned long, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x398e): In function `CDicomData::ST_SetValueDouble(int, long, double)':
: undefined reference to `DcmItem::putAndInsertFloat64(DcmTag const&, double, unsigned long, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x3a52): In function `CDicomData::ST_SetNextValueDouble(int,long, double)':
: undefined reference to `DcmItem::putAndInsertFloat64(DcmTag const&, double, unsigned long, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x3b13): In function `CDicomData::ST_SetValueFloat(int, long, float)':
: undefined reference to `DcmItem::putAndInsertFloat32(DcmTag const&, float, unsigned long, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x3bd5): In function `CDicomData::ST_SetNextValueFloat(int, long, float)':
: undefined reference to `DcmItem::putAndInsertFloat32(DcmTag const&, float, unsigned long, int)'
/home/shankari/DAL_Lib/DAL_Lib/libdal_lib.a(DicomData.o)(.text+0x3d34): In function `CDicomData::ST_SetPixelData(int, long,unsigned char*, long, bool (*)(int, unsigned long, int, unsigned char*, int, int))':
: undefined reference to `DcmItem::putAndInsertUint8Array(DcmTag const&, unsigned char const*, unsigned long, int)'
lib/libofstd.a(ofthread.o)(.text+0x170): In function `OFThread::join()':
: undefined reference to `pthread_join'
lib/libofstd.a(ofthread.o)(.text+0x395): In function `OFSemaphore::OFSemaphore(unsigned int)':
: undefined reference to `sem_init'
lib/libofstd.a(ofthread.o)(.text+0x3e3): In function `OFSemaphore::OFSemaphore(unsigned int)':
: undefined reference to `sem_init'
lib/libofstd.a(ofthread.o)(.text+0x41b): In function `OFSemaphore::~OFSemaphore()':
: undefined reference to `sem_destroy'
lib/libofstd.a(ofthread.o)(.text+0x449): In function `OFSemaphore::~OFSemaphore()':
: undefined reference to `sem_destroy'
lib/libofstd.a(ofthread.o)(.text+0x48d): In function `OFSemaphore::wait()':
: undefined reference to `sem_wait'
lib/libofstd.a(ofthread.o)(.text+0x4c1): In function `OFSemaphore::trywait()':
: undefined reference to `sem_trywait'
lib/libofstd.a(ofthread.o)(.text+0x4f5): In function `OFSemaphore::post()':
: undefined reference to `sem_post'
lib/libofstd.a(ofthread.o)(.text+0x716): In function `OFReadWriteLock::OFReadWriteLock()':
: undefined reference to `pthread_rwlock_init'
lib/libofstd.a(ofthread.o)(.text+0x760): In function `OFReadWriteLock::OFReadWriteLock()':
: undefined reference to `pthread_rwlock_init'
lib/libofstd.a(ofthread.o)(.text+0x797): In function `OFReadWriteLock::~OFReadWriteLock()':
: undefined reference to `pthread_rwlock_destroy'
lib/libofstd.a(ofthread.o)(.text+0x7c5): In function `OFReadWriteLock::~OFReadWriteLock()':
: undefined reference to `pthread_rwlock_destroy'
lib/libofstd.a(ofthread.o)(.text+0x809): In function `OFReadWriteLock::rdlock()':
: undefined reference to `pthread_rwlock_rdlock'
lib/libofstd.a(ofthread.o)(.text+0x829): In function `OFReadWriteLock::wrlock()':
: undefined reference to `pthread_rwlock_wrlock'
lib/libofstd.a(ofthread.o)(.text+0x849): In function `OFReadWriteLock::tryrdlock()':
: undefined reference to `pthread_rwlock_tryrdlock'
lib/libofstd.a(ofthread.o)(.text+0x869): In function `OFReadWriteLock::trywrlock()':
: undefined reference to `pthread_rwlock_trywrlock'
lib/libofstd.a(ofthread.o)(.text+0x889): In function `OFReadWriteLock::unlock()':
: undefined reference to `pthread_rwlock_unlock'
collect2: ld returned 1 exit status
make[1]: *** [/home/shankari/DAL_Lib/DAL_Lib/DALTests/DAL_Tests] Error 1
make: *** [default_target] Error 2

plz help me out with any solution.
thanks in advance,
shankari

Thomas Wilkens
DCMTK Developer
Posts: 117
Joined: Tue, 2004-11-02, 17:21
Location: Oldenburg, Germany
Contact:

#2 Post by Thomas Wilkens »

Aren't you compiling under Linux? In a previous thread you said so and from the command line dumps you provide it is kind of obvious.

If you are compiling under Linux, please note the following remark from the INSTALL file: "On Windows platforms (and only on Windows platforms!), the CMake utility can be used to turn the support for the above mentioned external libraries (OpenSSL, zlib, libtiff, libpng and libxml2) on or off manually (libwrap is currently not supported on Windows platforms)."

So the CMakeLists.txt files that come with DCMTK are not meant to be used under Linux. They are meant to be used on Windows Systems only. In fact, we have never tested compiling DCMTK based on CMake on any other platform but Windows, so we cannot help you in this respect.

How to compile DCMTK on Linux is thoroughly described in the INSTALL file. Make sure you have read and understood this file.

sivasankari
Posts: 20
Joined: Thu, 2005-03-10, 11:28
Location: India
Contact:

#3 Post by sivasankari »

I have NOT used the Cmake to compile dcmtk on LINUX. Instead,
I have compiled the dcmtk files as per the instructions given in the INSTALL file.
(./configure
make install)

I am getting the problem and the above-said errors when I link those dcmtk libraries with my own application DicomData, using Cmake under LINUX.


Please help me with needed solution

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

#4 Post by Marco Eichelberg »

On Linux, the link order of libraries is significant. Possibly you are not linking them in the correct order (e.g. -ldcmnet needs to be specified before -ldcmdata and this must be specified before -lofstd). A complete overview of library dependencies is provided in FAQ #27.

sivasankari
Posts: 20
Joined: Thu, 2005-03-10, 11:28
Location: India
Contact:

still having few errors!

#5 Post by sivasankari »

Thanks for your suggestion. It worked out well. But still i am getting few errors. I have arranged the dcmtk libraries in the order as given in DCMTK forum.
Now my cmakelists.txt look like this.
PROJECT(DAL)
BUILD_NAME(CMAKE_CXX_COMPILER)
IF(CMAKE_BACKWARDS_COMPATIBILITY GREATER 2.0)
SET(CMAKE_BACKWARDS_COMPATIBILITY 2.0 CACHE STRING
"Latest version of CMake when this project was released." FORCE)
ENDIF(CMAKE_BACKWARDS_COMPATIBILITY GREATER 2.0)

ADD_DEFINITIONS(-DHAVE_PTHREAD_H)
ADD_DEFINITIONS(-DWITH_THREADS)
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
ADD_DEFINITIONS(-DHAVE_PTHREAD_RWLOCK)
ADD_DEFINITIONS(-DUSE_STD_CXX_INCLUDES)
ADD_DEFINITIONS(-DHAVE_STD_NAMESPACE)
ADD_DEFINITIONS(-DHAVE_STRSTREAM)
ADD_DEFINITIONS(-DHAVE_CLASS_TEMPLATE)
ADD_DEFINITIONS(-DHAVE_FUNCTION_TEMPLATE)
ADD_DEFINITIONS(-DHAVE_CXX_VOLATILE)
ADD_DEFINITIONS(-DHAVE_SEMAPHORE_H)
ADD_DEFINITIONS(-D_REENTRANT)
INCLUDE_DIRECTORIES(
/home/DAL_Lib/DAL_Lib/
/home/DAL_Lib/DAL_Lib/dcmtk/dcmdata/include
/home/DAL_Lib/DAL_Lib/dcmtk/dcmimage/include
/home/DAL_Lib/DAL_Lib/dcmtk/dcmstat/include
/home/DAL_Lib/DAL_Lib/dcmtk/dcmsr/include
/home/DAL_Lib/DAL_Lib/dcmtk/dcmwlm/include
/home/DAL_Lib/DAL_Lib/dcmtk/dcmimgle/include
/home/DAL_Lib/DAL_Lib/dcmtk/dcmjpeg/include
/home/DAL_Lib/DAL_Lib/dcmtk/dcmnet/include
/home/DAL_Lib/DAL_Lib/dcmtk/dcmtls/include
/home/DAL_Lib/DAL_Lib/dcmtk/dcmsign/include
/home/DAL_Lib/DAL_Lib/dcmtk/imagectn/include
/home/DAL_Lib/DAL_Lib/dcmtk/config/include
/home/DAL_Lib/DAL_Lib/dcmtk/dcmjpeg/libijg12/include
/home/DAL_Lib/DAL_Lib/dcmtk/dcmjpeg/libijg16/include
/home/DAL_Lib/DAL_Lib/dcmtk/dcmjpeg/libijg8/include
/home/DAL_Lib/DAL_Lib/dcmtk/ofstd/include
/home/shankari/Source/Source/zlib-1.2.1/include
)
LINK_DIRECTORIES(

/home/DAL_Lib/DAL_Lib/dcmtk/dcmdata/libsrc
/home/DAL_Lib/DAL_Lib/dcmtk/dcmimage/libsrc
/home/DAL_Lib/DAL_Lib/dcmtk/dcmpstat/libsrc
/home/DAL_Lib/DAL_Lib/dcmtk/dcmsr/libsrc
/home/DAL_Lib/DAL_Lib/dcmtk/ofstd/libsrc
/home/DAL_Lib/DAL_Lib/dcmtk/dcmwlm/libsrc
/home/DAL_Lib/DAL_Lib/dcmtk/dcmimgle/libsrc
/home/DAL_Lib/DAL_Lib/dcmtk/dcmjpeg/libsrc
/home/DAL_Lib/DAL_Lib/dcmtk/dcmnet/libsrc
/home/DAL_Lib/DAL_Lib/dcmtk/dcmtls/libsrc
/home/DAL_Lib/DAL_Lib/dcmtk/dcmsign/libsrc
/home/DAL_Lib/DAL_Lib/dcmtk/imagectn/libsrc
/home/DAL_Lib/DAL_Lib/dcmtk/config/libsrc
/home/DAL_Lib/DAL_Lib/dcmtk/dcmjpeg/libijg12
/home/DAL_Lib/DAL_Lib/dcmtk/dcmjpeg/libijg16
/home/DAL_Lib/DAL_Lib/dcmtk/dcmjpeg/libijg8
/home/DAL_Lib/DAL_Lib/DALTests/lib
)
ADD_LIBRARY(DAL SHARED DicomData)

TARGET_LINK_LIBRARIES(DAL dcmpstat dcmwlm dcmjpeg dcmimage dcmimgle dcmdsig dcmsr imagedb dcmtls dcmnet dcmdata ofstd ijg8 ijg12 ijg16 z)
*************
Now , i get the following errors.

Building executable /home/DAL_Lib/DAL_Lib/DALTests/DAL_Tests...
lib/libDAL.so: undefined reference to `pthread_rwlock_rdlock'
lib/libDAL.so: undefined reference to `pthread_rwlock_init'
lib/libDAL.so: undefined reference to `sem_destroy'
lib/libDAL.so: undefined reference to `pthread_rwlock_destroy'
lib/libDAL.so: undefined reference to `sem_wait'
lib/libDAL.so: undefined reference to `sem_post'
lib/libDAL.so: undefined reference to `pthread_rwlock_unlock'
lib/libDAL.so: undefined reference to `sem_init'
lib/libDAL.so: undefined reference to `pthread_rwlock_wrlock'
lib/libDAL.so: undefined reference to `sem_trywait'
lib/libDAL.so: undefined reference to `pthread_rwlock_trywrlock'
lib/libDAL.so: undefined reference to `pthread_rwlock_tryrdlock'
lib/libDAL.so: undefined reference to `pthread_join'
collect2: ld returned 1 exit status
make[1]: *** [/home/DAL_Lib/DAL_Lib/DALTests/DAL_Tests] Error 1
make: *** [default_target] Error 2
[root@cactus DALTests]#

Please let me what the problem could be.
Thanks in advance,
shankari

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

#6 Post by Marco Eichelberg »

You are not linking all system libraries needed. In this case, -lpthread is missing. See config/Makefile.def for the various system libraries that DCMTK needs on your particular platform and configuration.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest