我有2个图书馆。 QtMultimedia和libqavfcamera。 libavfcamera依赖于QtMultimedia
我已经向QtMultimedia添加了一个类及其实现,并且它成功编译和链接。我可以验证(至少我认为)它包含我使用nm的实现:
$ nm -a -U -j /Users/mnelson/Projects/Surge/Accretive/qt/qt5/qtbase/lib/QtMultimedia.framework/Versions/Current/QtMultimedia | grep -i capab | c++filt
qt_meta_data_QCameraCapability
qt_meta_stringdata_QCameraCapability
QCameraCapability::qt_metacall(QMetaObject::Call, int, void**)
QCameraCapability::qt_metacast(char const*)
QCameraCapability::staticMetaObjectQCameraCapability::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)
QCameraCapability::QCameraCapability(QSize, double, double)
QCameraCapability::QCameraCapability(QCameraCapability const&)
QCameraCapability::QCameraCapability(QSize, double, double)
QCameraCapability::QCameraCapability(QCameraCapability const&)
QCameraCapability::~QCameraCapability()
QCameraCapability::~QCameraCapability()
QList<QCameraCapability>::QList(QList<QCameraCapability> const&)
QCameraInfo::capabilities() const
QCameraCapability::metaObject() const
QCameraCapability::resolution() const
QCameraCapability::maxFrameRate() const
QCameraCapability::minFrameRate() const
QMediaServiceProvider::cameraCapabilities(QByteArray const&) const
QPluginServiceProvider::cameraCapabilities(QByteArray const&) const
typeinfo for QCameraCapability
typeinfo name for QCameraCapability
vtable for QCameraCapability
但是当我尝试链接该库时,我得到了一个&#34;未定义的符号,用于架构x86_64&#34;:
$ "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -v -demangle -dynamic -dylib -arch x86_64 -headerpad_max_install_names -macosx_version_min 10.7.0 -single_module -o libqavfcamera_debug.dylib -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk .obj/debug/avfcameraserviceplugin.o .obj/debug/avfcameracontrol.o .obj/debug/avfvideorenderercontrol.o .obj/debug/avfcamerametadatacontrol.o .obj/debug/avfimagecapturecontrol.o .obj/debug/avfmediarecordercontrol.o .obj/debug/avfcameraservice.o .obj/debug/avfcamerasession.o .obj/debug/avfstoragelocation.o .obj/debug/avfvideodevicecontrol.o .obj/debug/avfaudioinputselectorcontrol.o .obj/debug/avfcamerainfocontrol.o .obj/debug/avfcameraviewfindersettingscontrol.o .obj/debug/moc_avfcameraserviceplugin.o .obj/debug/moc_avfcamerainfocontrol.o .obj/debug/moc_avfcameraviewfindersettingscontrol.o -framework AudioToolbox -framework CoreAudio -framework QuartzCore -framework AVFoundation -framework CoreMedia -framework AppKit -framework AudioUnit -framework QtMultimedia -framework QtGui -framework QtCore -framework QtNetwork -framework OpenGL -framework AGL -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/lib/darwin/libclang_rt.osx.a -F/Users/mnelson/Projects/Surge/Accretive/qt/qt5/qtbase/lib
@(#)PROGRAM:ld PROJECT:ld64-236.4
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 armv6m armv7m armv7em
Library search paths:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib
Framework search paths:
/Users/mnelson/Projects/Surge/Accretive/qt/qt5/qtbase/lib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/
Undefined symbols for architecture x86_64:
"QCameraCapability::QCameraCapability(QSize, double, double)", referenced from:
AVFCameraSession::updateCameraDevices() in avfcamerasession.o
ld: symbol(s) not found for architecture x86_64
QCameraCapability :: QCameraCapability(QSize,double,double)肯定会出现。路径看起来正确。不知道为什么它会在那里两次。
我是OS X上的c ++ dev的新手,所以我很可能(希望)遗漏了一些明显的东西。
答案 0 :(得分:0)
我明白了。感谢您的评论,因为他们引导我找到解决方案。
在没有-j选项的情况下运行nm确实很有启发性。
$ nm -a -arch x86_64 QtMultimedia | grep resolution | c++filt
000000000005eef0 T QCameraViewfinderSettings::resolutionChanged(QSize)
0000000000047290 T QMediaResource::resolution() const
000000000002dff0 unsigned short QCameraCapability::resolution() const
0000000000050d70 T QImageEncoderSettings::resolution() const
0000000000050610 T QVideoEncoderSettings::resolution() const
000000000002ce90 T QCameraViewfinderSettings::resolution() const
我正在向QtMultimedia库添加代码,而新添加的类缺少导出宏Q_MULTIMEDIA_EXPORT。
添加宏并重新编译nm输出后如下:
$ nm -a -arch x86_64 -U QtMultimedia | grep resolution | c++filt
000000000005f0f0 T QCameraViewfinderSettings::resolutionChanged(QSize)
0000000000047490 T QMediaResource::resolution() const
000000000002e1f0 T QCameraCapability::resolution() const
0000000000050f70 T QImageEncoderSettings::resolution() const
0000000000050810 T QVideoEncoderSettings::resolution() const
000000000002d090 T QCameraViewfinderSettings::resolution() const
之后,它链接得很好。