0

I'm getting the following linker errors...

/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&)'

(shortened for brevity, full log here)

when using g++ to link, I am passing -lIlmImf-2_5, I've checked this file with `nm' and it seems to have the symbols that the linker is looking for.

$ 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()
...

Does anyone know how to fix this?

Edit: I now understand that the order of the libs matters, thanks n-1-8e9. However I still have some problems I can't sort out.

/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()'

This error message tells me that I need -lglslang after -lshaderc_util but I already have it that way...

-lshaderc -lshaderc_util -lglslang -lglslang-default-resource-limits

How do I fix it?

David Carpenter
  • 1,389
  • 2
  • 16
  • 29
  • 1
    Does this answer your question? [Why does the order in which libraries are linked sometimes cause errors in GCC?](https://stackoverflow.com/questions/45135/why-does-the-order-in-which-libraries-are-linked-sometimes-cause-errors-in-gcc) – n. m. could be an AI Aug 01 '22 at 06:21
  • I had actually just found this other answer and I think I'm making progress. Didn't understand how this worked before now. https://stackoverflow.com/questions/10456581/undefined-reference-to-symbol-even-when-nm-indicates-that-this-symbol-is-present – David Carpenter Aug 01 '22 at 06:25
  • 1
    This is discussed here https://community.khronos.org/t/reciving-a-undefined-refrence-for-glslang-functions-with-g/106466/6 (the function is not where you think it is, you need to add more libraries). – n. m. could be an AI Aug 01 '22 at 07:17

0 Answers0