Mac Error: Undefined symbols for architecture x86_64

匿名 (未验证) 提交于 2019-12-03 01:00:01

问题:

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 

回答1:

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 


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!