/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.21′ not found

The solution is simple, your binary was linked to a different version of libstdc++

Don’t try in vain to find a compiler option to force some earlier version to be used during linking.

Just install a different version of g++ and complile all your code and any static librabries you depend on with it.

I was compiling OpenCV in Ubuntu 16 and was using g++ version 5 with libstd++.so.6 -> /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
But my production environment is Ubuntu 14 with libstd++.so.6 -> /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19

The solution was to install g++-4.8 rebuild everything and run my binaries successfully in the production environment.

apt-get install g++-4.8
#Regarding OpenCV compilation set the appropriate compliler in options
cmake -DCMAKE_C_COMPILER=gcc-4.8 -DCMAKE_CXX_COMPILER=g++-4.8

Cheers 🙂