提问人:David Carpenter 提问时间:8/1/2022 最后编辑:David Carpenter 更新时间:8/1/2022 访问量:358
链接 - 未定义的引用
linking - undefined references
问:
我收到以下链接器错误...
/bin/ld: /home/david/C/vcpkg/installed/x64-linux/lib/libFreeImage.a(PluginEXR.cpp.o): in function `InitEXR(Plugin*, int)': PluginEXR.cpp:(.text+0x2ab): undefined reference to `Imf_2_5::staticInitialize()' /bin/ld: /home/david/C/vcpkg/installed/x64-linux/lib/libFreeImage.a(PluginEXR.cpp.o): in function `Save(FreeImageIO*, FIBITMAP*, void*, int, int, void*)': PluginEXR.cpp:(.text+0x45b): undefined reference to `iex_debugTrap()' /bin/ld: PluginEXR.cpp:(.text+0x639): undefined reference to `Imf_2_5::OStream::OStream(char const*)' /bin/ld: PluginEXR.cpp:(.text+0x719): undefined reference to `Imf_2_5::Header::Header(Imath_2_5::Box<Imath_2_5::Vec2<int> > const&, Imath_2_5::Box<Imath_2_5::Vec2<int> > const&, float, Imath_2_5::Vec2<float> const&, float, Imf_2_5::LineOrder, Imf_2_5::Compression)' /bin/ld: PluginEXR.cpp:(.text+0x7db): undefined reference to `iex_debugTrap()' /bin/ld: PluginEXR.cpp:(.text+0x9ac): undefined reference to `iex_debugTrap()' /bin/ld: PluginEXR.cpp:(.text+0xbe1): undefined reference to `Imf_2_5::PreviewImage::PreviewImage(unsigned int, unsigned int, Imf_2_5::PreviewRgba const*)' /bin/ld: PluginEXR.cpp:(.text+0xd4e): undefined reference to `Imf_2_5::Header::channels()' /bin/ld: PluginEXR.cpp:(.text+0xd70): undefined reference to `Imf_2_5::Channel::Channel(Imf_2_5::PixelType, int, int, bool)' /bin/ld: PluginEXR.cpp:(.text+0xd86): undefined reference to `Imf_2_5::ChannelList::insert(char const*, Imf_2_5::Channel const&)'
(为简洁起见,此处为完整日志)
使用 g++ 链接时,我传递了 -lIlmImf-2_5,我已经用“nm”检查了这个文件,它似乎具有链接器正在寻找的符号。
$ nm --demangle libIlmImf-2_5.a | grep staticInit
0000000000000ec0 T Imf_2_5::staticInitialize()
0000000000000033 t Imf_2_5::staticInitialize() [clone .cold]
0000000000000000 b Imf_2_5::staticInitialize()::initialized
0000000000000020 b Imf_2_5::staticInitialize()::criticalSection
$ nm --demangle libIlmImf-2_5.a | grep iex
U iex_debugTrap()
U iex_debugTrap()
U iex_debugTrap()
U iex_debugTrap()
U iex_debugTrap()
...
有谁知道如何解决这个问题?
编辑:我现在明白库的顺序很重要,谢谢n-1-8e9。但是,我仍然有一些无法解决的问题。
/bin/ld: /home/david/C/vcpkg/installed/x64-linux/lib/libshaderc_util.a(compiler.cc.o): in function `shaderc_util::GlslangInitializer::GlslangInitializer()':
compiler.cc:(.text+0x59): undefined reference to `glslang::InitializeProcess()'
这条错误消息告诉我我需要之后,但我已经这样了......-lglslang
-lshaderc_util
-lshaderc -lshaderc_util -lglslang -lglslang-default-resource-limits
我该如何解决?
答: 暂无答案
评论