我已经通过 brew 安装了 DCMTK,并且在 qt 上配置了它,添加了指向库的路径。当我尝试打开 DICOM 图像并运行项目时,出现以下 2 个错误:
体系结构 x86_64 的 undefined symbol :
“DicomImage::DicomImage(char const*, unsigned long, unsigned long, unsigned long)”,引用自:
MainWindow::on_pushButton_clicked() 在 mainwindow.o
ld: 找不到体系结构 x86_64 的符号
clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
make: *** [testDicom.app/Contents/MacOS/testDicom] 错误 1
21:04:21:进程“/usr/bin/make”以代码 2 退出。
构建/部署项目 testDicom 时出错(套件:桌面 Qt 5.12.1 clang 64 位)
执行步骤“Make”时
21:04:21:耗时: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
最佳答案
问题已解决,我将解决方案发布在这里,因为它可能对某些人有帮助。 当您包含 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
关于c++ - Mac 中带有 qt 的 DCMTK 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55837066/