#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;} elsecerr << "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'
你能帮我修一下这个错误吗?谢谢.
解决方法 看起来您希望find_library
调用使用3个单独的库填充变量DINIFTI_DCMTK_liB. 这不是find_library的工作原理. nameS之后的不同参数表示可以调用单个库的所有各种名称.这允许命令跨平台工作,其中相同的库可以在不同平台上被称为不同的东西.
一个小问题是你可能更喜欢在这里使用PATHS而不是HINTS.形成文档:
… the
HINTS
option … should be paths computed by system introspection,such as a hint provIDed by the location of another item already found. Hard-coded guesses should be specifIEd with thePATHS
option.
我想你想要更像的东西:
find_library(DINIFTI_DCMTK_liB nameS dcmdata PATHS ${liBDIR})find_library(OFSTD_liB nameS ofstd PATHS ${liBDIR})find_library(OFLOG_liB nameS oflog PATHS ${liBDIR})target_link_librarIEs(dinifti ${DINIFTI_DCMTK_liB} ${OFLOG_liB} ${OFSTD_liB} ${DINIFTI_ZNZ_liB} ${CMAKE_THREAD_liBS_INIT} z)总结
以上是内存溢出为你收集整理的c – 如何使用CMake链接多个库全部内容,希望文章能够帮你解决c – 如何使用CMake链接多个库所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)