我有一些与 DCMTK 相关的代码。如果我从命令行使用 g++,我可以成功构建并运行它。这是代码:
#include "dcmtk/config/osconfig.h"
#include "dcmtk/dcmdata/dctk.h"
int main()
{
DcmFileFormat fileformat;
OFCondition status = fileformat.loadFile("test.dcm");
if (status.good())
{
OFString patientsName;
if (fileformat.getDataset()->findAndGetOFString(DCM_PatientsName, patientsName).good())
{
cout << "Patient's Name: " << patientsName << endl;
} else
cerr << "Error: cannot access Patient's Name!" << endl;
} else
cerr << "Error: cannot read DICOM file (" << status.text() << ")" << endl;
return 0;
}
这是构建命令:
g++ testeapp.cxx -DHAVE_CONFIG_H -I/path_to_dcmtk/include -L/path_to_dcmtk/lib -pthread -ldcmdata -lz -loflog -lofstd -o main
我想制作一个 CMakeLists.txt 以在 Kdevelop 中构建它。这是我目前拥有的:
# Configure toplevel directories
SET( PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "Top level.")
SET( INCLUDEDIR ${PREFIX}/include CACHE PATH "Include files.")
SET( LIBDIR ${PREFIX}/lib CACHE PATH "Libraries.")
FIND_PACKAGE ( Threads REQUIRED )
# Configure DCMTK
FIND_PATH( DINIFTI_DCMTK_INCLUDE dcmtk
PATHS ${INCLUDEDIR}
PATH_SUFFIXES dcmtk
DOC "Path to the DCMTK headers." )
FIND_LIBRARY(DINIFTI_DCMTK_LIB NAMES dcmdata ofstd oflog
HINTS ${LIBDIR} ${LIBDIR})
TARGET_LINK_LIBRARIES( dinifti ${DINIFTI_DCMTK_LIB}
${DINIFTI_ZNZ_LIB}
${CMAKE_THREAD_LIBS_INIT}
z )
但是当我构建它时,它有这个错误:
/usr/local/lib/libdcmdata.a(dcfilefo.o): In function `DcmFileFormat::remove(DcmItem*)':
dcfilefo.cc:(.text+0x1788): undefined reference to `log4cplus::Logger::forcedLog(int, OFString const&, char const*, int, char const*) const'
你能帮我解决这个错误吗?谢谢你。