icpc error: namespace "std" has no member "function" or "bind" or other

Affects OS X and some older Linux distributions

Error message is seen when compiling C++11 C++ applications using std::function. 

Root cause:  stdlib headers and libraries used by ICPC come from the system supplied gnu gcc/g++ by default.  Thus the system g++ must be fairly modern and support std::function.  Older gcc versions such as those found on OS X and some older Linux distributions do not have full support for all new C++11 std:: namespace functions.  You will see an error such as this:

$ icpc -std=c++11 test.cpp
test.cpp(19): error: namespace "std" has no member "function"


OS X:  The ICPC compiler option -stdlib=libc++ can be used to force icpc to use the CLANG supplied stdlib headers and libraries instead of the GNU stdlib headers and libraries:

icpc -std=c++11 -stdlib=libc++ test.cpp

Linux:  If you can, update your gcc/g++ installation to get the latest C++11 feature support.

There is a bug report to get the default OS X behavior to be -stdlib=libc++ so that the option does not need to be explicitly added.





For more complete information about compiler optimizations, see our Optimization Notice.