我正在尝试在MacOS上编译libopenshot。
运行构建时,在链接过程中出现以下错误:
→ make VERBOSE=1
...
/usr/local/bin/g++-4.9 -std=c++11 -g -ggdb -fopenmp -g -dynamiclib -Wl,-headerpad_max_install_names -compatibility_version 14.0.0 -current_version 0.1.9 -o libopenshot.0.1.9.dylib -install_name /source/libopenshot/build/src/libopenshot.14.dylib CMakeFiles/openshot.dir/AudioBufferSource.cpp.o CMakeFiles/openshot.dir/AudioReaderSource.cpp.o CMakeFiles/openshot.dir/AudioResampler.cpp.o CMakeFiles/openshot.dir/CacheBase.cpp.o CMakeFiles/openshot.dir/CacheDisk.cpp.o CMakeFiles/openshot.dir/CacheMemory.cpp.o CMakeFiles/openshot.dir/ChunkReader.cpp.o CMakeFiles/openshot.dir/ChunkWriter.cpp.o CMakeFiles/openshot.dir/Color.cpp.o CMakeFiles/openshot.dir/Clip.cpp.o CMakeFiles/openshot.dir/ClipBase.cpp.o CMakeFiles/openshot.dir/Coordinate.cpp.o CMakeFiles/openshot.dir/CrashHandler.cpp.o CMakeFiles/openshot.dir/DummyReader.cpp.o CMakeFiles/openshot.dir/ReaderBase.cpp.o CMakeFiles/openshot.dir/RendererBase.cpp.o CMakeFiles/openshot.dir/WriterBase.cpp.o CMakeFiles/openshot.dir/EffectBase.cpp.o CMakeFiles/openshot.dir/effects/Bars.cpp.o CMakeFiles/openshot.dir/effects/Blur.cpp.o CMakeFiles/openshot.dir/effects/Brightness.cpp.o CMakeFiles/openshot.dir/effects/ChromaKey.cpp.o CMakeFiles/openshot.dir/effects/ColorShift.cpp.o CMakeFiles/openshot.dir/effects/Crop.cpp.o CMakeFiles/openshot.dir/effects/Deinterlace.cpp.o CMakeFiles/openshot.dir/effects/Hue.cpp.o CMakeFiles/openshot.dir/effects/Mask.cpp.o CMakeFiles/openshot.dir/effects/Negate.cpp.o CMakeFiles/openshot.dir/effects/Pixelate.cpp.o CMakeFiles/openshot.dir/effects/Saturation.cpp.o CMakeFiles/openshot.dir/effects/Shift.cpp.o CMakeFiles/openshot.dir/effects/Wave.cpp.o CMakeFiles/openshot.dir/EffectInfo.cpp.o CMakeFiles/openshot.dir/FFmpegReader.cpp.o CMakeFiles/openshot.dir/FFmpegWriter.cpp.o CMakeFiles/openshot.dir/Fraction.cpp.o CMakeFiles/openshot.dir/Frame.cpp.o CMakeFiles/openshot.dir/FrameMapper.cpp.o CMakeFiles/openshot.dir/KeyFrame.cpp.o CMakeFiles/openshot.dir/ZmqLogger.cpp.o CMakeFiles/openshot.dir/PlayerBase.cpp.o CMakeFiles/openshot.dir/Point.cpp.o CMakeFiles/openshot.dir/Profiles.cpp.o CMakeFiles/openshot.dir/QtImageReader.cpp.o CMakeFiles/openshot.dir/QtPlayer.cpp.o CMakeFiles/openshot.dir/Timeline.cpp.o CMakeFiles/openshot.dir/Qt/AudioPlaybackThread.cpp.o CMakeFiles/openshot.dir/Qt/PlayerDemo.cpp.o CMakeFiles/openshot.dir/Qt/PlayerPrivate.cpp.o CMakeFiles/openshot.dir/Qt/VideoCacheThread.cpp.o CMakeFiles/openshot.dir/Qt/VideoPlaybackThread.cpp.o CMakeFiles/openshot.dir/Qt/VideoRenderWidget.cpp.o CMakeFiles/openshot.dir/Qt/VideoRenderer.cpp.o CMakeFiles/openshot.dir/__/include/Qt/moc_AudioPlaybackThread.cpp.o CMakeFiles/openshot.dir/__/include/Qt/moc_PlayerDemo.cpp.o CMakeFiles/openshot.dir/__/include/Qt/moc_PlayerPrivate.cpp.o CMakeFiles/openshot.dir/__/include/Qt/moc_VideoCacheThread.cpp.o CMakeFiles/openshot.dir/__/include/Qt/moc_VideoPlaybackThread.cpp.o CMakeFiles/openshot.dir/__/include/Qt/moc_VideoRenderWidget.cpp.o CMakeFiles/openshot.dir/__/include/Qt/moc_VideoRenderer.cpp.o CMakeFiles/openshot.dir/__/thirdparty/jsoncpp/src/lib_json/json_reader.cpp.o CMakeFiles/openshot.dir/__/thirdparty/jsoncpp/src/lib_json/json_value.cpp.o CMakeFiles/openshot.dir/__/thirdparty/jsoncpp/src/lib_json/json_writer.cpp.o CMakeFiles/openshot.dir/ImageReader.cpp.o CMakeFiles/openshot.dir/ImageWriter.cpp.o CMakeFiles/openshot.dir/TextReader.cpp.o /usr/local/opt/ffmpeg@2.8/lib/libavformat.dylib /usr/local/opt/ffmpeg@2.8/lib/libavcodec.dylib /usr/local/opt/ffmpeg@2.8/lib/libavutil.dylib /usr/local/opt/ffmpeg@2.8/lib/libavdevice.dylib /usr/local/opt/ffmpeg@2.8/lib/libswscale.dylib /usr/local/opt/ffmpeg@2.8/lib/libavresample.dylib /usr/local/lib/libopenshot-audio.dylib /usr/local/Cellar/qt/5.9.0/lib/QtMultimediaWidgets.framework/QtMultimediaWidgets /usr/local/lib/libzmq.dylib -fopenmp /usr/local/opt/imagemagick@6/lib/libMagick++-6.Q16.dylib /usr/local/opt/imagemagick@6/lib/libMagickWand-6.Q16.dylib /usr/local/opt/imagemagick@6/lib/libMagickCore-6.Q16.dylib /usr/local/Cellar/qt/5.9.0/lib/QtWidgets.framework/QtWidgets /usr/local/Cellar/qt/5.9.0/lib/QtMultimedia.framework/QtMultimedia /usr/local/Cellar/qt/5.9.0/lib/QtGui.framework/QtGui /usr/local/Cellar/qt/5.9.0/lib/QtNetwork.framework/QtNetwork /usr/local/Cellar/qt/5.9.0/lib/QtCore.framework/QtCore
Undefined symbols for architecture x86_64:
"Magick::DrawableFont::DrawableFont(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
openshot::TextReader::Open() in TextReader.cpp.o
"Magick::DrawableText::DrawableText(double, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
openshot::TextReader::Open() in TextReader.cpp.o
"Magick::Color::Color(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
openshot::TextReader::Open() in TextReader.cpp.o
"Magick::Image::draw(std::list<Magick::Drawable, std::allocator<Magick::Drawable> > const&)", referenced from:
openshot::TextReader::Open() in TextReader.cpp.o
"Magick::Image::magick(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
openshot::ImageWriter::WriteFrame(std::shared_ptr<openshot::Frame>) in ImageWriter.cpp.o
"Magick::Image::Image(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
openshot::ImageReader::Open() in ImageReader.cpp.o
"Magick::Image::Image(unsigned long, unsigned long, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, MagickCore::StorageType, void const*)", referenced from:
openshot::Frame::GetMagickImage() in Frame.cpp.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[2]: *** [src/libopenshot.0.1.9.dylib] Error 1
make[1]: *** [src/CMakeFiles/openshot.dir/all] Error 2
make: *** [all] Error 2
看起来编译器可以找到它:
→ make TextReader.i && grep DrawableFont CMakeFiles/openshot.dir/TextReader.cpp.i
Preprocessing CXX source to CMakeFiles/openshot.dir/TextReader.cpp.i
class __attribute__ ((visibility ("default"))) DrawableFont : public DrawableBase
DrawableFont ( const std::string &font_ );
DrawableFont ( const std::string &family_,
DrawableFont ( const DrawableFont& original_ );
~DrawableFont ( void );
lines.push_back(Magick::DrawableFont(font));
我不知道为什么链接程序找不到这些符号。我不知道如何读取符号表,但看起来它们可能在库中。
→ nm -arch x86_64 -gU /usr/local/opt/imagemagick@6/lib/libMagick++-6.Q16.dylib | grep DrawableFont
0000000000009780 T __ZN6Magick12DrawableFontC1ERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE
0000000000009842 T __ZN6Magick12DrawableFontC1ERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEN10MagickCore9StyleTypeEjNSA_11StretchTypeE
00000000000098c2 T __ZN6Magick12DrawableFontC1ERKS0_
0000000000009736 T __ZN6Magick12DrawableFontC2ERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE
00000000000097ca T __ZN6Magick12DrawableFontC2ERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEN10MagickCore9StyleTypeEjNSA_11StretchTypeE
000000000000984c T __ZN6Magick12DrawableFontC2ERKS0_
0000000000009914 T __ZN6Magick12DrawableFontD0Ev
000000000000990a T __ZN6Magick12DrawableFontD1Ev
00000000000098cc T __ZN6Magick12DrawableFontD2Ev
00000000000099e0 T __ZNK6Magick12DrawableFont4copyEv
0000000000009942 T __ZNK6Magick12DrawableFontclEPN10MagickCore12_DrawingWandE
000000000002e230 S __ZTIN6Magick12DrawableFontE
00000000000298b0 S __ZTSN6Magick12DrawableFontE
000000000002d060 S __ZTVN6Magick12DrawableFontE
有什么想法可能是错误的,或者我还应该尝试诊断什么错误?
答案 0 :(得分:1)
自C ++ 11起,ABI(应用程序二进制接口)已更改。这意味着,如果您的某些依赖项是使用C ++ 98兼容性编译的,而另一些依赖项是使用兼容性优于或等于C ++ 11的兼容性编译的,则符号名称的分辨率可能并不总是相同。
因此,您的链接器正在尝试链接具有不同名称的相同符号。
解决方案:使用相同的兼容ABI重新编译所有依赖项。就您而言,您应该只使用-std = c ++ 11标志重新编译所有内容。