我正在做一个小型C ++项目,需要从DICOM TAG中提取信息。
我正在使用VSCode来管理C ++代码,并使用CMake来构建。
通过Macport安装的DCMTK:端口安装dcmtk。
如何将DCMTK作为库添加到我的项目中?有分步教程吗?
谢谢!
这是我根据@mattdibi所做的
在我的CMakeLists.txt中添加了以下几行
find_package(DCMTK REQUIRED)
include_directories(${DCMTK_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} tinyxml2 ${DCMTK_LIBRARIES})
然后在文件c_cpp_properties.json中的“ includePath”部分添加了包含路径“ / opt / local / include”。
在我的源文件中添加了包含行:
#include "dcmtk/dcmdata/dctk.h"
#include "dcmtk/dcmimgle/dcmimage.h"
cd到项目根目录中的我的Debug文件夹,运行cmake -DCMAKE_BUILD_TYPE = Debug ..
最后,在Debug文件夹下运行make,以下是带有错误的构建日志:
[ 50%] Built target tinyxml2
[ 75%] Building CXX object CMakeFiles/SURMaker.dir/MakerApp.cpp.o
In file included from /Users/adminuser/Documents/Playground/SURMaker/MakerApp.cpp:5:
In file included from /opt/local/include/dcmtk/dcmdata/dctk.h:28:
In file included from /opt/local/include/dcmtk/dcmdata/dctypes.h:27:
In file included from /opt/local/include/dcmtk/oflog/oflog.h:32:
In file included from /opt/local/include/dcmtk/ofstd/ofconapp.h:29:
In file included from /opt/local/include/dcmtk/ofstd/ofcmdln.h:32:
In file included from /opt/local/include/dcmtk/ofstd/offile.h:30:
In file included from /opt/local/include/dcmtk/ofstd/ofstd.h:33:
In file included from /opt/local/include/dcmtk/ofstd/oflimits.h:88:
In file included from /opt/local/include/dcmtk/ofstd/ofstdinc.h:219:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:313:9: error: no member named 'signbit' in the global namespace; did you
mean 'sigwait'?
using ::signbit;
~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/signal.h:101:5: note: 'sigwait' declared here
int sigwait(const sigset_t * __restrict, int * __restrict) __DARWIN_ALIAS_C(sigwait);
^
In file included from /Users/adminuser/Documents/Playground/SURMaker/MakerApp.cpp:5:
In file included from /opt/local/include/dcmtk/dcmdata/dctk.h:28:
In file included from /opt/local/include/dcmtk/dcmdata/dctypes.h:27:
In file included from /opt/local/include/dcmtk/oflog/oflog.h:32:
In file included from /opt/local/include/dcmtk/ofstd/ofconapp.h:29:
In file included from /opt/local/include/dcmtk/ofstd/ofcmdln.h:32:
In file included from /opt/local/include/dcmtk/ofstd/offile.h:30:
In file included from /opt/local/include/dcmtk/ofstd/ofstd.h:33:
In file included from /opt/local/include/dcmtk/ofstd/oflimits.h:88:
In file included from /opt/local/include/dcmtk/ofstd/ofstdinc.h:219:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:314:9: error: no member named 'fpclassify' in the global namespace
using ::fpclassify;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:315:9: error: no member named 'isfinite' in the global namespace; did you
mean 'finite'?
using ::isfinite;
~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:749:12: note: 'finite' declared here
extern int finite(double)
^
In file included from /Users/adminuser/Documents/Playground/SURMaker/MakerApp.cpp:5:
In file included from /opt/local/include/dcmtk/dcmdata/dctk.h:28:
In file included from /opt/local/include/dcmtk/dcmdata/dctypes.h:27:
In file included from /opt/local/include/dcmtk/oflog/oflog.h:32:
In file included from /opt/local/include/dcmtk/ofstd/ofconapp.h:29:
In file included from /opt/local/include/dcmtk/ofstd/ofcmdln.h:32:
In file included from /opt/local/include/dcmtk/ofstd/offile.h:30:
In file included from /opt/local/include/dcmtk/ofstd/ofstd.h:33:
In file included from /opt/local/include/dcmtk/ofstd/oflimits.h:88:
In file included from /opt/local/include/dcmtk/ofstd/ofstdinc.h:219:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:316:9: error: no member named 'isinf' in the global namespace
using ::isinf;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:317:9: error: no member named 'isnan' in the global namespace
using ::isnan;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:318:9: error: no member named 'isnormal' in the global namespace
using ::isnormal;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:319:7: error: no member named 'isgreater' in the global namespace; did you
mean '::std::greater'?
using ::isgreater;
^~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/functional:720:29: note: '::std::greater' declared here
struct _LIBCPP_TEMPLATE_VIS greater : binary_function<_Tp, _Tp, bool>
^
In file included from /Users/adminuser/Documents/Playground/SURMaker/MakerApp.cpp:5:
In file included from /opt/local/include/dcmtk/dcmdata/dctk.h:28:
In file included from /opt/local/include/dcmtk/dcmdata/dctypes.h:27:
In file included from /opt/local/include/dcmtk/oflog/oflog.h:32:
In file included from /opt/local/include/dcmtk/ofstd/ofconapp.h:29:
In file included from /opt/local/include/dcmtk/ofstd/ofcmdln.h:32:
In file included from /opt/local/include/dcmtk/ofstd/offile.h:30:
In file included from /opt/local/include/dcmtk/ofstd/ofstd.h:33:
In file included from /opt/local/include/dcmtk/ofstd/oflimits.h:88:
In file included from /opt/local/include/dcmtk/ofstd/ofstdinc.h:219:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:320:7: error: no member named 'isgreaterequal' in the global namespace;
did you mean '::std::greater_equal'?
using ::isgreaterequal;
^~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/functional:749:29: note: '::std::greater_equal' declared here
struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool>
^
In file included from /Users/adminuser/Documents/Playground/SURMaker/MakerApp.cpp:5:
In file included from /opt/local/include/dcmtk/dcmdata/dctk.h:28:
In file included from /opt/local/include/dcmtk/dcmdata/dctypes.h:27:
In file included from /opt/local/include/dcmtk/oflog/oflog.h:32:
In file included from /opt/local/include/dcmtk/ofstd/ofconapp.h:29:
In file included from /opt/local/include/dcmtk/ofstd/ofcmdln.h:32:
In file included from /opt/local/include/dcmtk/ofstd/offile.h:30:
In file included from /opt/local/include/dcmtk/ofstd/ofstd.h:33:
In file included from /opt/local/include/dcmtk/ofstd/oflimits.h:88:
In file included from /opt/local/include/dcmtk/ofstd/ofstdinc.h:219:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:321:9: error: no member named 'isless' in the global namespace
using ::isless;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:322:9: error: no member named 'islessequal' in the global namespace
using ::islessequal;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:323:9: error: no member named 'islessgreater' in the global namespace
using ::islessgreater;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:324:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:325:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
~~^
13 errors generated.
make[2]: *** [CMakeFiles/SURMaker.dir/MakerApp.cpp.o] Error 1
make[1]: *** [CMakeFiles/SURMaker.dir/all] Error 2
make: *** [all] Error 2
答案 0 :(得分:1)
有一个CMake module。
添加您的CMakeLists.txt文件:
...
find_package(DCMTK REQUIRED)
include_directories(${DCMTK_INCLUDE_DIRS})
add_executable(EXE main.cpp)
target_link_libraries(EXE ${DCMTK_LIBRARIES})
...