3

I compiled the below code on the compilation machine with mentioned configuration. The compilation was successful. But got the above error on executing ldd -r my_executable

#include <iostream>
#include <list>
using namespace std;

int main()
{
    list<int> mylist;
    mylist.push_back(1);
    mylist.push_back(2);
    mylist.push_back(3);

    cout << "\nList:\n";
    for(list<int>::iterator it = mylist.begin(); it != mylist.end(); it++)
    {
        cout << *it << "\n";
    }
}

Compiling machine details: glibc version 2.14.1 libstdc++ version GLIBCXX_3.4.16 (output after running command : strings /usr/lib/libstdc++.so.6 | grep LIBCXX )

Target machine details: glibc version 2.12.90 libstdc++ version GLIBCXX_3.4.14 (output after running command : strings /usr/lib/libstdc++.so.6 | grep LIBCXX )

5
  • @usar, you don't need to in C++, there's an implicit return 0; Aug 12, 2014 at 12:26
  • @Sayali, every version of libstdc++.so.6 contains GLIBCXX_3.4, you need to look for the newest symbol version it contains, not the oldest. You probably don't have a new enough libstdc++ on the target machine, or you need to read gcc.gnu.org/onlinedocs/libstdc++/faq.html#faq.how_to_set_paths and the docs it links to. Aug 12, 2014 at 12:27
  • Open up /usr/include/<GCC Version>/<arch triplet>/bits/c++config.h and look for the definition of the macro _GLIBCXX_BEGIN_NAMESPACE_VERSION in both the host and build systems. If they're different, there's your problem. Aug 12, 2014 at 12:34
  • @themoondothshine, nonsense. That has nothing to do with it. Aug 12, 2014 at 13:01
  • Of course it does Mr. Wakely :) list_node_base::_M_hook is defined in that namespace. To make sure there are no version conflicts! Aug 13, 2014 at 16:25

1 Answer 1

1

You have built your program on a machine with one version of GCC and so your program depends on the shared libraries from that version of GCC, then you are trying to run it on a machine with an older version of GCC, which does not have the necessary shared libraries.

There are hundreds of answers about this on StackOverflow already. The simplest answer is to just build the program on the target machine, so it is built with the version of GCC that exists on the target machine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.