c++ - 在 Linux 上编译错误但在 MacOSX 上没有

标签 c++ linux gcc compilation compiler-errors

我正在尝试编译一个用 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 包含标题,我猜,这就是它在那里工作的原因。

关于c++ - 在 Linux 上编译错误但在 MacOSX 上没有,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29832546/

相关文章:

macos - cmake 不断添加 std=gnu++11 选项

c++ - 父线程终止时子线程是否退出

linux - 创建等于文件中行的变量,并按顺序为变量分配文件中的值

c++ - 我如何从文件 C++ 中读取并输出它

linux - 总是在 Linux 上将 sendfile 与 nginx 一起使用吗?

c++ - 在 Makefile 中指定库路径

objective-c - 将 Objective-C 文件编译成目标文件 (.o)

c++ - 如何设置QListWidget第一个/最后一个项目的样式?

c++ - 将对象插入集合失败

c++ - 使用 ucnv_convert() 时为韩语显示垃圾字符