I'm attempting to write my own DcmStorageSCP using DCMTK (latest GitHub source as of 6/2/2022). My server doesn't care about the entire DICOM file though, just a few parameters of it, which the program will save to an XML file. One of the requirements is that the included libraries must be statically linked (or very easy to distribute). I believe I have successfully built a static version of DCMTK, but I am having issues linking in my CMake file. The following image details my ccmake configuration:
As expected the toolkit is installed to /usr/local/dcmtk and /usr/local/dcmtk/lib contains static (.a) libraries.
Question 1)
Using this setup, will I still need to include openjpeg, iconv, icu, threads, tiff, xml, and zlib into my own project cmake? I'm under the impression DCMTK_LINK_STATIC will magically do this for me.
I already have a bit of source code written for my own DcmStorageSCP using dynamic linking previously, though it has turned into more of a "Hello, World!" with extra includes. My CMakeLists.txt includes the following:
Code: Select all
#Generated by VisualGDB project wizard.-3.6.7-install/usr/local/lib
#Note: VisualGDB will automatically update this file when you add new sources to the project.
cmake_minimum_required(VERSION 2.7)
project(IOLMasterDICOM)
set(DCMTK_DIR "/usr/local/dcmtk")
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(DCMTK_USE_STATIC_LIBS "ON")
find_package(DCMTK REQUIRED)
message("DCMTK_INCLUDE_DIRS: " ${DCMTK_INCLUDE_DIRS})
message("DCMTK_LIBRARIES: " ${DCMTK_LIBRARIES})
message("DCMTK_DIR: " ${DCMTK_DIR})
# add_executable(IOLMasterDICOM tinyxml.h tinystr.cpp tinyxml.cpp tinyxmlerror.cpp tinyxmlparser.cpp tinystr.h IOLMDcmStorageSCP.h IOLMDcmStorageSCP.cpp IOLMasterDICOM.cpp)
add_executable(IOLMasterDICOM IOLMasterDICOM.cpp)
target_include_directories(IOLMasterDICOM PRIVATE ${DCMTK_INCLUDE_DIRS})
target_link_libraries(IOLMasterDICOM ${DCMTK_LIBRARIES})
FILE(COPY storescp.cfg DESTINATION "${CMAKE_BINARY_DIR}")
set_property(TARGET IOLMasterDICOM PROPERTY CXX_STANDARD 17)
Code: Select all
Running CMake: cmake ../../.. -G "Ninja" -DCMAKE_BUILD_TYPE=DEBUG
-- Trying to find DCMTK expecting DCMTKConfig.cmake
-- Trying to find DCMTK expecting DCMTKConfig.cmake - ok
DCMTK_INCLUDE_DIRS: /usr/local/dcmtk/include
DCMTK_LIBRARIES: ofstdoflogdcmdatai2ddcmxmldcmimgledcmimagedcmjpegijg8ijg12ijg16dcmjplsdcmtkcharlsdcmtlsdcmnetdcmsrcmrdcmdsigdcmwlmdcmqrdbdcmpstatdcmrtdcmioddcmfgdcmsegdcmtractdcmpmapdcmect
DCMTK_DIR: /usr/local/dcmtk/lib/cmake/dcmtk
-- Configuring done
-- Generating done
-- Build files have been written to: /home/x/IOLMasterDICOM/build/VisualGDB/Debug
========== Project Configuration Summary ==========
IOLMasterDICOM configured in 00:01
========== Configuration: 1 Succeeded, 0 Failed, 0 Skipped ==========
Code: Select all
Run "ninja " in directory "/home/x/IOLMasterDICOM/build/VisualGDB/Debug" on x@x-linux (SSH)
ninja
[0/1] Linking CXX executable IOLMasterDICOM
[1/1] Linking CXX executable IOLMasterDICOM
FAILED: IOLMasterDICOM
: && /usr/bin/c++ -g -rdynamic CMakeFiles/IOLMasterDICOM.dir/IOLMasterDICOM.cpp.o -o IOLMasterDICOM -lofstd -loflog -ldcmdata -li2d -ldcmxml -ldcmimgle -ldcmimage -ldcmjpeg -lijg8 -lijg12 -lijg16 -ldcmjpls -ldcmtkcharls -ldcmtls -ldcmnet -ldcmsr -lcmr -ldcmdsig -ldcmwlm -ldcmqrdb -ldcmpstat -ldcmrt -ldcmiod -ldcmfg -ldcmseg -ldcmtract -ldcmpmap -ldcmect && :
/usr/bin/ld: cannot find -lofstd
/usr/bin/ld: cannot find -loflog
/usr/bin/ld: cannot find -ldcmdata
/usr/bin/ld: cannot find -ldcmxml
/usr/bin/ld: cannot find -ldcmimgle
/usr/bin/ld: cannot find -ldcmimage
/usr/bin/ld: cannot find -ldcmjpeg
/usr/bin/ld: cannot find -ldcmjpls
/usr/bin/ld: cannot find -ldcmtkcharls
/usr/bin/ld: cannot find -ldcmtls
/usr/bin/ld: cannot find -ldcmnet
/usr/bin/ld: cannot find -ldcmsr
/usr/bin/ld: cannot find -ldcmdsig
/usr/bin/ld: cannot find -ldcmwlm
/usr/bin/ld: cannot find -ldcmqrdb
/usr/bin/ld: cannot find -ldcmpstat
/usr/bin/ld: cannot find -ldcmrt
/usr/bin/ld: cannot find -ldcmiod
/usr/bin/ld: cannot find -ldcmfg
/usr/bin/ld: cannot find -ldcmseg
/usr/bin/ld: cannot find -ldcmtract
/usr/bin/ld: cannot find -ldcmpmap
/usr/bin/ld: cannot find -ldcmect
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
-------------------------------------------------------------
Command exited with code 1
Executable: ninja
Arguments:
Directory: /home/x/IOLMasterDICOM/build/VisualGDB/Debug
Command-line action failed
========== Project Build Summary ==========
IOLMasterDICOM built in 00:00
========== Build: 0 Succeeded, 1 Failed, 0 Skipped ==========
Question 2)
What gives? The install directory contains all the files needed to statically link DCMTK and the cmake identifies the folder. Why does target_link_libraries link dynamically causing my build to fail?
To summarize my goal again, I'm basically trying to create a binary in the likes of storescp without any unnecessary installs for distribution to NAS servers. Been pulling my hair out for some time permuting many different fixes, so any help is appreciated greatly