DCMTK 库与 mac 中的 qt

Posted

技术标签:

【中文标题】DCMTK 库与 mac 中的 qt【英文标题】:DCMTK library with qt in mac 【发布时间】:2019-04-24 19:12:54 【问题描述】:

我已经通过 brew 安装了 DCMTK,并且我已经在 qt 上对其进行了配置,并添加了指向库的路径。当我尝试打开 DICOM 图像并运行项目时,出现以下 2 个错误: Undefined symbols for architecture x86_64: "DicomImage::DicomImage(char const*, unsigned long, unsigned long, unsigned long)", referenced from: MainWindow::on_pushButton_clicked() in mainwindow.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [testDicom.app/Contents/MacOS/testDicom] Error 1 21:04:21: The process "/usr/bin/make" exited with code 2. Error while building/deploying project testDicom (kit: Desktop Qt 5.12.1 clang 64bit) When executing step "Make" 21:04:21: Elapsed time: 00:00. 我该如何解决?

更新(这是我的 file.pro):

#
# Project created by QtCreator 2019-04-24T20:43:01
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = testDicom
TEMPLATE = app

# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

CONFIG += c++11

SOURCES += \
        main.cpp \
        mainwindow.cpp

HEADERS += \
        mainwindow.h

INCLUDEPATH += /usr/local/Cellar/dcmtk/3.6.4/include \


LIBS += -L/usr/local/lib \
        -L/usr/local/Cellar/dcmtk/3.6.4/lib \
        -L/usr/local/Cellar/dcmtk/3.6.4/bin


FORMS += \
        mainwindow.ui

# Default rules for deployment.
qnx: target.path = /tmp/$$TARGET/bin
else: unix:!android: target.path = /opt/$$TARGET/bin
!isEmpty(target.path): INSTALLS += target

【问题讨论】:

感谢您的回复,我已经添加了我的 .pro 文件 【参考方案1】:

问题解决了,我在这里发布解决方案,因为它可能对某人有所帮助。 当您包含 dcmtk 时,您还必须包含 zlib 和 libiconv。

INCLUDEPATH += /usr/local/Cellar/dcmtk/3.6.4/include \ /usr/local/opt/zlib/lib/include

LIBS += -L/usr/local/lib \ -L/usr/local/Cellar/opencv/4.1.0_1/lib\ -L/usr/local/Cellar/dcmtk/3.6.4/lib\ -ldcmdata\ -ldcmimgle \ -ldcmjpeg\ -loflog\ -ldcmpstat \ -lofstd\ -liconv \ -lz

【讨论】:

以上是关于DCMTK 库与 mac 中的 qt的主要内容,如果未能解决你的问题,请参考以下文章

使用 Mac OS X 应用程序部署 Qt - 如何不加载任何插件?

vs2019_qt6.2.4_dcmtk3.6.7_vtk9.2.2_itk5.3_opencv4.6.0编译记录

vs2019_qt6.2.4_dcmtk3.6.7_vtk9.2.2_itk5.3_opencv4.6.0编译记录

vs2019_qt6.2.4_dcmtk3.6.7_vtk9.2.2_itk5.3_opencv4.6.0编译记录

dcmtk lnk2019 无法解析外部符号

DCMTK 的奇怪库行为