Mac错误:体系结构x86_64的未定义符号 [英] Mac Error: Undefined symbols for architecture x86_64

查看:518
本文介绍了Mac错误:体系结构x86_64的未定义符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试安装 MIT语言建模工具包。我已经安装了依赖项,并且 ./ autogen.sh 工作正常。但是,当我使用 make 编译时,出现下面的错误。

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


推荐答案

使用C ++ 11?

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附带两个版本的标准库,较旧的 libstdc ++ 和较新的 libc ++ 。后者只支持C ++ 11。更多详细信息可以在答案中找到。

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.

编辑:

根据来源,让您的构建系统知道您对编译器标志的更改,请尝试以下操作:

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

这篇关于Mac错误:体系结构x86_64的未定义符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆