Как использовать DCMTK в проекте C ++ на MacOS - PullRequest
0 голосов
/ 25 января 2019

Я работаю над небольшим проектом C ++ для извлечения информации из тегов DICOM.

Я использую VSCode для управления кодом C ++ и CMake для сборки.

DCMTK установлен через Macport: порт install dcmtk.

Как добавить DCMTK в качестве библиотеки в мой проект? Есть ли пошаговое руководство?

Спасибо!

UPDATE:

Вот что я сделал в соответствии с @ mattdibi

Добавлены следующие строки в мой CMakeLists.txt

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

Затем добавлено включение пути "/ opt / local / include" в раздел "includePath" в файле c_cpp_properties.json.

Добавлены строки включения в мой исходный файл:

#include "dcmtk/dcmdata/dctk.h"
#include "dcmtk/dcmimgle/dcmimage.h"

перейдите в мою папку Debug в корне проекта, запустите cmake -DCMAKE_BUILD_TYPE = Debug ..

Наконец, запустите make в папке Debug, следующий журнал сборки с ошибками:

[ 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

1 Ответ

0 голосов
/ 25 января 2019

Для этого есть модуль CMake .

Добавьте в свой файл CMakeLists.txt:

...
find_package(DCMTK REQUIRED)

include_directories(${DCMTK_INCLUDE_DIRS})
add_executable(EXE main.cpp)
target_link_libraries(EXE ${DCMTK_LIBRARIES})
...
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...