Linux 上的编译错误,但 MacOSX 上没有

Compilation error on Linux but not on MacOSX

我正在尝试编译用 C++ 编码的程序。它在 Mac OSX 上完美编译,但在 Linux 上编译失败。我一直在 Linux 上尝试在两个独立的集群 运行 上进行编译,但都无法编译。

这是我遇到的错误:

src/LCEcomposite.cc:513: error: no matching function for call to ‘find(__gnu_cxx::__normal_iterator > >, __gnu_cxx::__normal_iterator > >, unsigned int&)’

这是导致问题的代码行(LCEcomposite.cc 中的第 513 行)

if(find(_TraitIndices.begin(), _TraitIndices.end(), i) == _TraitIndices.end()) {

这是 Linux

上的 make 版本
gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) 

这是 Linux

上的 gcc 版本
GNU Make 3.81
This program built for x86_64-redhat-linux-gnu

这是uname -a

的输出
Linux seawolf2 2.6.32-358.18.1.el6.x86_64 #1 SMP Wed Aug 28 17:19:38 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

将此添加到您的代码中:

#include <algorithm>

Mac 包含了 header 无论如何,我猜,这就是它在那里工作的原因。