libmediainfo: qt5 项目未定义符号错误
libmediainfo: qt5 project undefined symbol errors
我正在尝试将 libmediainfo 与我的 qt5 项目一起使用,但出现以下错误
Undefined symbols for architecture x86_64:
"MediaInfoLib::MediaInfo::Open(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&)", referenced from:
MainWindow::on_dupeslistWidget_itemClicked(QListWidgetItem*) in mainwindow.o
"MediaInfoLib::MediaInfo::Option(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&)", referenced from:
MainWindow::on_dupeslistWidget_itemClicked(QListWidgetItem*) 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: *** [VideoTwin.app/Contents/MacOS/VideoTwin] Error 1
19:56:12: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project VideoTwin (kit: default)
When executing step "Make"
我的 .pro 文件
QT += core gui
QT += sql
QT += concurrent
QT += multimedia multimediawidgets
INCLUDEPATH += /usr/local/include /usr/local/Cellar/opencv3/3.1.0_1/include/ $$[QT_INSTALL_PREFIX]/src/3rdparty/sqlite
LIBS += -L/usr/local/Cellar/opencv3/3.1.0_1/lib -L/usr/local/lib -lmediainfo -lzen -lz -lpthread -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_cvv -lopencv_dnn -lopencv_dpm -lopencv_fuzzy -lopencv_line_descriptor -lopencv_optflow -lopencv_plot -lopencv_reg -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_rgbd -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_face -lopencv_xfeatures2d -lopencv_shape -lopencv_video -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_flann -lopencv_xobjdetect -lopencv_objdetect -lopencv_ml -lopencv_xphoto -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_photo -lopencv_imgproc -lopencv_core
QMAKE_CXXFLAGS += -D_UNICODE -DUNICODE
QMAKE_CFLAGS += -D_UNICODE -DUNICODE
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = VideoTwin
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
preferencsedialog.cpp \
myqlistwidget.cpp \
$$[QT_INSTALL_PREFIX]/src/3rdparty/sqlite/sqlite3.c \
matchpair.cpp
HEADERS += mainwindow.h \
preferencsedialog.h \
myqlistwidget.h \
matchpair.h
FORMS += mainwindow.ui \
preferencsedialog.ui
RESOURCES += \
resources.qrc
在我的头文件中
#include <MediaInfo/MediaInfo.h>
和 cpp 的相关部分
MediaInfoLib::MediaInfo media_info;
media_info.Option(L"Internet",L"No");
media_info.Open(item->data(Qt::UserRole + FilepathRole).toString().toStdWString());
QString temp = QString::fromWCharArray( media_info.Inform().c_str(),media_info.Inform().length());
ui->video_info->setText(temp);
ui->video_info->show();
我不确定问题出在哪里。我在 /usr/local/lib 目录中有 libmediaplayer.dylib。请帮助
你没有告诉 Qt libmediainfo.dylib 在哪里,所以 Qt 找不到它。
您需要将其添加到您的 .pro 文件中,例如:
LIBS += $$system(pkg-config --libs libmediainfo)
您可以拥有 more examples about how to configure your .pro file in order to link to libmediainfo.dylib,具体取决于 libmediainfo.dylib 在您系统上的位置。
链接到静态库并使用 "dll" 头文件对我有用:
将其放入您的源代码中
#include "MediaInfoDLL/MediaInfoDLL_Static.h"
using namespace MediaInfoDLL;
这是.pro文件的内容
QT += core
QT -= gui
TARGET = QtTestMediaInfo
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
# Adjust this to where you put the source code of MediaInfo
MEDIA_INFO_DIR=~/Downloads/MediaInfo_CLI_GNU_FromSource
#INCLUDEPATH += $${MEDIA_INFO_DIR}/ZenLib/Source
INCLUDEPATH += $${MEDIA_INFO_DIR}/MediaInfoLib/Source
LIBS += -L$${MEDIA_INFO_DIR}/MediaInfoLib/Project/GNU/Library -lmediainfo
LIBS += -L$${MEDIA_INFO_DIR}/ZenLib/Project/GNU/Library -lzen -lz
祝你好运!
我正在尝试将 libmediainfo 与我的 qt5 项目一起使用,但出现以下错误
Undefined symbols for architecture x86_64:
"MediaInfoLib::MediaInfo::Open(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&)", referenced from:
MainWindow::on_dupeslistWidget_itemClicked(QListWidgetItem*) in mainwindow.o
"MediaInfoLib::MediaInfo::Option(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&)", referenced from:
MainWindow::on_dupeslistWidget_itemClicked(QListWidgetItem*) 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: *** [VideoTwin.app/Contents/MacOS/VideoTwin] Error 1
19:56:12: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project VideoTwin (kit: default)
When executing step "Make"
我的 .pro 文件
QT += core gui
QT += sql
QT += concurrent
QT += multimedia multimediawidgets
INCLUDEPATH += /usr/local/include /usr/local/Cellar/opencv3/3.1.0_1/include/ $$[QT_INSTALL_PREFIX]/src/3rdparty/sqlite
LIBS += -L/usr/local/Cellar/opencv3/3.1.0_1/lib -L/usr/local/lib -lmediainfo -lzen -lz -lpthread -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_cvv -lopencv_dnn -lopencv_dpm -lopencv_fuzzy -lopencv_line_descriptor -lopencv_optflow -lopencv_plot -lopencv_reg -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_rgbd -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_face -lopencv_xfeatures2d -lopencv_shape -lopencv_video -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_flann -lopencv_xobjdetect -lopencv_objdetect -lopencv_ml -lopencv_xphoto -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_photo -lopencv_imgproc -lopencv_core
QMAKE_CXXFLAGS += -D_UNICODE -DUNICODE
QMAKE_CFLAGS += -D_UNICODE -DUNICODE
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = VideoTwin
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
preferencsedialog.cpp \
myqlistwidget.cpp \
$$[QT_INSTALL_PREFIX]/src/3rdparty/sqlite/sqlite3.c \
matchpair.cpp
HEADERS += mainwindow.h \
preferencsedialog.h \
myqlistwidget.h \
matchpair.h
FORMS += mainwindow.ui \
preferencsedialog.ui
RESOURCES += \
resources.qrc
在我的头文件中
#include <MediaInfo/MediaInfo.h>
和 cpp 的相关部分
MediaInfoLib::MediaInfo media_info;
media_info.Option(L"Internet",L"No");
media_info.Open(item->data(Qt::UserRole + FilepathRole).toString().toStdWString());
QString temp = QString::fromWCharArray( media_info.Inform().c_str(),media_info.Inform().length());
ui->video_info->setText(temp);
ui->video_info->show();
我不确定问题出在哪里。我在 /usr/local/lib 目录中有 libmediaplayer.dylib。请帮助
你没有告诉 Qt libmediainfo.dylib 在哪里,所以 Qt 找不到它。
您需要将其添加到您的 .pro 文件中,例如:
LIBS += $$system(pkg-config --libs libmediainfo)
您可以拥有 more examples about how to configure your .pro file in order to link to libmediainfo.dylib,具体取决于 libmediainfo.dylib 在您系统上的位置。
链接到静态库并使用 "dll" 头文件对我有用:
将其放入您的源代码中
#include "MediaInfoDLL/MediaInfoDLL_Static.h"
using namespace MediaInfoDLL;
这是.pro文件的内容
QT += core
QT -= gui
TARGET = QtTestMediaInfo
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
# Adjust this to where you put the source code of MediaInfo
MEDIA_INFO_DIR=~/Downloads/MediaInfo_CLI_GNU_FromSource
#INCLUDEPATH += $${MEDIA_INFO_DIR}/ZenLib/Source
INCLUDEPATH += $${MEDIA_INFO_DIR}/MediaInfoLib/Source
LIBS += -L$${MEDIA_INFO_DIR}/MediaInfoLib/Project/GNU/Library -lmediainfo
LIBS += -L$${MEDIA_INFO_DIR}/ZenLib/Project/GNU/Library -lzen -lz
祝你好运!