我正在尝试安装MIT Language Modeling Toolkit。我已经安装了依赖项,./autogen.sh
工作正常。但是,当我使用make
进行编译时,我收到以下错误。我正在运行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
答案 0 :(得分:3)
库有可能使用C ++ 11吗?
您必须添加以下编译器标志:
-std=c++11 -stdlib=libc++
Mac OSX附带两个版本的标准库,旧的libstdc++
和较新的libc++
。 C ++ 11仅受后者支持。有关详细信息,请参阅此answer。
修改强>
根据此source,要使构建系统了解对编译器标志的更改,请尝试以下操作:
$ 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