gpt4 book ai didi

c++ - 为什么找不到这些符号?

转载 作者:行者123 更新时间:2023-11-28 04:37:01 24 4
gpt4 key购买 nike

我正在尝试在 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

知道可能出了什么问题或者我应该尝试诊断此错误的其他方法吗?

最佳答案

自 C++11 以来,ABI(应用程序二进制接口(interface))发生了变化。这意味着,如果您的某些依赖项是使用 C++98 兼容性编译的,而其他依赖项是使用兼容性优于或等于 C++11 的,则符号名称的解析可能并不总是相同。

因此,您的链接器正在尝试链接具有不同名称的相同符号。

解决方案:使用相同的兼容 ABI 重新编译所有依赖项。在您的情况下,您应该使用 -std=c++11 标志重新编译所有内容。

关于c++ - 为什么找不到这些符号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51122417/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com