gpt4 book ai didi

c++ - 如何在macOS上的C++项目中使用DCMTK

转载 作者:行者123 更新时间:2023-11-28 04:25:51 25 4
gpt4 key购买 nike

我正在开发一个小型 C++ 项目,需要从 DICOM TAG 中提取信息。

我正在使用 VSCode 管理 C++ 代码并使用 CMake 进行构建。

DCMTK 通过 Macport 安装:port install dcmtk。

如何将 DCMTK 作为库添加到我的项目中?有没有一步一步的教程?

谢谢!

更新:

这是我根据@mattdibi 所做的

在我的 CMakeLists.txt 中添加了以下行

find_package(DCMTK REQUIRED)
include_directories(${DCMTK_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} tinyxml2 ${DCMTK_LIBRARIES})

然后将包含路径“/opt/local/include”添加到文件 c_cpp_properties.json 中的“includePath”部分。

在我的源文件中添加了包含行:

#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

最佳答案

有一个 CMake module为此。

在您的 CMakeLists.txt 文件中添加:

...
find_package(DCMTK REQUIRED)

include_directories(${DCMTK_INCLUDE_DIRS})
add_executable(EXE main.cpp)
target_link_libraries(EXE ${DCMTK_LIBRARIES})
...

关于c++ - 如何在macOS上的C++项目中使用DCMTK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54369556/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com