2

I'm trying to install the MIT Language Modeling Toolkit. I've installed the dependencies, and ./autogen.sh works fine. However, when I compile with make, I get the error below. I am running OSX 10.10.3.

Undefined symbols for architecture x86_64:
  "std::__detail::_Prime_rehash_policy::_M_need_rehash(unsigned long, unsigned long, unsigned long) const", referenced from:
      std::_Hashtable<unsigned long, std::pair<unsigned long const, int>, std::allocator<std::pair<unsigned long const, int> >, std::__detail::_Select1st, std::equal_to<unsigned long>, std::hash<unsigned long>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::_M_insert_unique_node(unsigned long, unsigned long, std::__detail::_Hash_node<std::pair<unsigned long const, int>, false>*) in evaluate-ngram.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[1]: *** [evaluate-ngram] Error 1
make: *** [all-recursive] Error 1
Adam_G
  • 7,337
  • 20
  • 86
  • 148

1 Answers1

3

Is it possible that the library uses C++11?

You'll have to add the following compiler flags:

-std=c++11 -stdlib=libc++

Mac OSX comes with two versions of the Standard Library, the older libstdc++ and the newer libc++. C++11 is only supported by the latter. More details can be found in this answer.

EDIT:

According to this source, to make your build system aware of your changes to the compiler flags, try the following:

$ export CXXFLAGS="-std=c++11 -stdlib=libc++"
$ export CC=`which clang` # optional step to make sure clang is being used
$ export CXX=`which clang++` # optional step to make sure clang is being used
$ ./autogen.sh
$ make
Community
  • 1
  • 1
nils
  • 2,424
  • 1
  • 17
  • 31
  • Thanks. So would I add those flags to `make`, i.e. run `make -std=c++11 -stdlib=libc++`? – Adam_G Apr 12 '15 at 12:03
  • No, they should be added before the configure step. I'll update my answer. – nils Apr 12 '15 at 12:06
  • Thanks for the update. Since I've already run `./autogen.sh` and `make`, should I just run `make clean` before rerunning the commands? – Adam_G Apr 12 '15 at 12:20
  • I'm not sure if it is a must, but I would advise you to run at least `make clean` or even better, remove all build-related files. – nils Apr 12 '15 at 12:57
  • Thanks, but this now produces the error `g++: error: unrecognized command line option '-stdlib=libc++'` – Adam_G Apr 12 '15 at 18:31
  • What version of the g++ are you using? – nils Apr 13 '15 at 07:27
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/75085/discussion-between-nils-and-adam-g). – nils Apr 13 '15 at 07:30
  • Could you provide an explanation of clang, or point me to a good doc? – Adam_G Apr 14 '15 at 13:11
  • Clang is Apple's attempt to replace the GCC. The [Wikipedia article](http://en.wikipedia.org/wiki/Clang) should be a good start. – nils Apr 14 '15 at 13:49