Adam_G
Adam_G

Reputation: 7879

Mac Error: Undefined symbols for architecture x86_64

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

Upvotes: 2

Views: 9681

Answers (1)

nils
nils

Reputation: 2524

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

Upvotes: 4

Related Questions