I’m building C++ code in Eclipse CDT with g++ and I’m getting the following linker error:
Undefined symbols for architecture x86_64:
"std::__throw_bad_function_call()", referenced from:
std::function<void (graphics::RenderingContext*)>::operator()(graphics::RenderingContext*) const in GameWindow.o
I have std::function members in a class called GameWindow.
Is there something I have to link to in order to get code using std::function to link properly?
Turns out my lib path wasn’t set correctly for g++.
For posterity: I use gcc 4.7 for compiling because I need C++11 features. XCode (on OS X Mountain Lion), ships with gcc 4.2 so I installed gcc 4.7 through Homebrew.
For Eclipse to compile with gcc 4.7, I had to change the path to the compiler and linker in project settings to correspond to the newly installed via Homebrew version. However, I still had the old library path to the gcc 4.2 stdlibc++ in my project settings.