Build WSTP Programs on OSX 10.10 and Mathematica 10

I tried to write a C/C++ program which talks with Mathematica via the WSTP protocol. However, when I build the program using the Makefile provided in directory /Applications/, clang++ complains during linking that

Undefined symbols for architecture x86_64:
  "std::__basic_file::is_open() const", referenced from:
      WSTP::MLLog::logSelectorToFileWithName(WSTP::mllogselector, char const*) in libWSTPi4.a(mllog.cpp.o)

This is because the libWSTPi4.a file bundled with Mathematica 10 was built with libstdc++ on Mac OS X. Therefore, a solution is to add link flag -stdlib=libstdc++ explicitly in the Makefile. For example:

factor : factor.o
        ${CXX} ${EXTRA_CFLAGS} -I${INCDIR} factor.o -L${LIBDIR} -lWSTPi4 -lm -lpthread -stdlib=libstdc++ -lstdc++ -framework Foundation -o $@

An alternative solution is to libraries in /Applications/