Dmitry Cherezov
Dmitry Cherezov

Reputation: 33

Static linking DCMTK library

I use DCMTK in my application and for compilation use cmake file. cmake finds all libraries (at least headers, because in compiles source files to .o files) the only problem is that during linking it tries to find dynamic libraries for DCMTK. I compiled one as static, so I do not have .so files. As a result it gives me error :No rule to make target /usr/lib/libdcmdata.so, needed by dcm_seg. Stop.

I use Ubuntu 14.04 x64.

It confuses me pretty much. So, what's the problems?

cmake file:

cmake_minimum_required(VERSION 2.6)

project(dcm_segm)

set(CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS} -g -ftest-coverage -fprofile-arcs")

set(Boost_USE_STATIC_LIBS ON)
set(OpenCV_USE_STATIC_LIBS ON)
set(DCMTK_USE_STATIC_LIBS ON)
set(OpenCV_STATIC ON)

find_package( VTK REQUIRED )
find_package( OpenCV REQUIRED )
find_package( Boost COMPONENTS system filesystem REQUIRED )
find_package( DCMTK  REQUIRED )

include(${VTK_USE_FILE} )

link_directories(${OpenCV_LIB_DIR})

add_executable(dcm_seg main.cpp DICOMin.cpp Ensemble.cpp Ensemble3dExtension.cpp point_3d.cpp RegionGrow.cpp)

target_link_libraries(dcm_seg ${VTK_LIBRARIES} ${OpenCV_LIBS} ${DCMTK_LIBRARIES} ${Boost_LIBRARIES})

Upvotes: 1

Views: 1930

Answers (1)

Can you check the content of ${DCMTK_LIBRARIES} (it should be a list of paths to DCMTK static libraries) ?

you can also check the following CMake entries during the CMake configuration:

 DCMTK_DIR                        /path/to/DCMTK/install
 DCMTK_config_INCLUDE_DIR         /path/to/DCMTK/install/include/dcmtk/config
 DCMTK_dcmdata_INCLUDE_DIR        /path/to/DCMTK/install/dcmdata/include/dcmtk/dcmdata
 DCMTK_dcmdata_LIBRARY_DEBUG      /path/to/DCMTK/install/dcmdata/libsrc/libdcmdata.a
 DCMTK_dcmdata_LIBRARY_RELEASE    /path/to/DCMTK/install/dcmdata/libsrc/libdcmdata.a
[...]

Another hint: I noted in the past that find DCMTK from a build instead of an install not always works properly.

If you have trouble finding DCMTK with the script provided with CMake (${DCMTK_LIBRARIES} doesn not content the path to you static DCMTK libs for example) you can try to use this alternative script

Upvotes: 1

Related Questions