'Versions of GLIBC
I have created c++ application in Ubuntu machine. I have copied binary to Centos machine. Got error:
/usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.21' not found
I decided to check which versions of glibc I have in my machines with help of ldd --version command:
Ubuntu: 2.23
Centos6.9: 2.12
Why CentOS cmplains regarding GLIBCXX_3.4.21, while Ubuntu owns glibc version 2.23?
Solution 1:[1]
The symbols like GLIBCXX_3.4.21
are generated by the compiler to mark which version of the C++ library that the compilation was used with (in particular, non-inline functions called from header-files & template functions). This is the libstdc++ library, not glibc.
The version that you are looking for is your libstdc++ - and this is one of the interesting problems with C++, the template library tends to change every now and again, so a function may be declared as unsigned int func()
, and later someone decides to change it to size_t func()
. No difference in 32-bit machines, but for 64-bit machines it DOES make a difference, and using the "wrong" version will lead to problems with the size of the return value.
There are a few different solutions (and this is not a complete list):
- Make sure you use the same version of libstdc++ on both machines.
- Compile the code on the target machine.
- Use static libstdc++
Solution 2:[2]
This a great - I used the -static option in the link and it solved by problem also.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Mats Petersson |
Solution 2 |