0

I am working on a project which needs to be executed in a Linux machine that has turned out not to have the GLIBCXX_3.4.20 version of a library, but the code needs it. Is there anyway to find which part of my code (C++) asks for this version?

I read the ELF file using objdump and realdef and I found which symbol needs it: _ZSt24__throw_out_of_rang@GLIBCXX_3.4.20 (4) but I don't know to which part of my code can be related.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Bituki
  • 43
  • 1
  • 6
  • I don't really now how, but my problem was solved using the same code but compiling it in another project (I am using Code Blocks). The library was required by the function std::string:substr, but I didn't make any change except changing the project. Maybe some option on the gcc compiling options caused the problem, although I didn't found any difference between both projects. – Bituki May 18 '15 at 08:03

1 Answers1

1

Your question is essentially a duplicate of this question.

Except in your case, it's not libc.so.6, but libstdc++.so that's giving you trouble.

Your problem is that you are compiling with new GCC, but are running on a machine with an old libstdc++.so.

You have a few options:

  • you can update target machine to have a new enough libstdc++.so
  • you can build using older version of GCC
  • you could use -static-libstdc++ flag to link required version of libstdc++ directly into your application. This will make a larger binary, but it will not be using libstdc++.so at all.

    Note that if you link against other shared libraries that do link against libstdc++.so, your binary may not run correctly on the target machine, so this solution should be used with caution.
Community
  • 1
  • 1
Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • The only option could have been building it with an older GCC, the other two were constratints on this project. However, the problem solved somehow without this change. – Bituki May 16 '15 at 14:35