无法编译任何C++代码
Unable to compile any C++ Code
每当我试图用IOStream编译C++文件时,我都会收到这个错误。。我试着重新安装GCC G++(4.6和4.9)and cpp。。它没有起到任何作用(或者可能我做得不对)。我如何修复这个错误
In file included from /usr/include/c++/4.9/bits/localefwd.h:40:0,
from /usr/include/c++/4.9/ios:41,
from /usr/include/c++/4.9/ostream:38,
from /usr/include/c++/4.9/iostream:39,
from Integration_Any.cpp:1:
/usr/include/x86_64-linux-gnu/c++/4.9/bits/c++locale.h:52:23: error:‘uselocale’was not declared in this scope
extern "C" __typeof(uselocale) __uselocale;
^
/usr/include/x86_64-linux-gnu/c++/4.9/bits/c++locale.h:52:45: error: invalid type in declaration before ‘;’ token
extern "C" __typeof(uselocale) __uselocale;
^
/usr/include/x86_64-linux-gnu/c++/4.9/bits/c++locale.h: In function ‘int std::__convert_from_v(__locale_struct* const&, char*, int, const char*, ...)’: /usr/include/x86_64-linux-gnu/c++/4.9/bits/c++locale.h:75:53: error: ‘__gnu_cxx::__uselocale’ cannot be used as a function
__c_locale __old = __gnu_cxx::__uselocale(__cloc);
^
/usr/include/x86_64-linux-gnu/c++/4.9/bits/c++locale.h:100:33: error: ‘__gnu_cxx::__uselocale’ cannot be used as a function
__gnu_cxx::__uselocale(__old);
^
当我在RHEL5上构建GCC,然后在RHEL7上运行它时,会出现此错误。
根本原因是GCC构建中的fixincludes
机制。这将从生成系统上的/usr/include
复制(并修改)各种标头到<prefix>/lib/gcc/x86_64-pc-linux-gnu/<version>/include-fixed/
。来自RHEL5的这些报头中的一些在RHEL7上引起编译错误;固定的";通过CCD_ 4。
我的解决方案只是从include-fixed
目录中删除这些头:
features.h
pthread.h
wchar.h
sys/stat.h
bits/string2.h
删除这些之后,我的编译错误就消失了。
我在使用openmpi和更新版本的g++时看到了同样的错误。您可能使用的是使用另一个C++编译器编译的mpi安装。比较mpicxx-v和g++-v的输出。我猜mpicxx-v将显示一个比你旧的g++版本,并用你正在使用的新g++版本重新安装你的mpi。
相关文章:
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 代码在main()中运行,但在函数中出现错误
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- 编译包含字符串的代码时遇到问题
- 我在c++代码中生成了一个运行时#3异常
- 如何在linux终端中同时编译和运行c++代码
- 为cl.exe(Visual Studio代码)指定命令行C++版本
- 在Linux for Windows上编译C++代码时出错
- 我的字符计数代码计算错误.为什么
- 孤立代码块在结构中引发异常
- 在编译C++代码(具有dlib和opencv)到WASM时面临问题
- 为什么我的C#代码在调用回C++COM直到Task时会暂停.等待/线程.加入
- 处理小于cpu数据总线的数据类型.(c++转换为机器代码)
- 此代码是否违反一个定义规则
- 为什么我的代码在输出中增加了93天
- 我的简单if-else语句是如何无法访问的代码
- 使用动态分配的数组会导致代码分析发出虚假的C6386缓冲区溢出警告
- 为什么在这个代码结束循环中没有得到结束
- 在c代码之间共享数据的最佳方式
- 这个指针和内存代码打印是什么?我不知道是打印垃圾还是如何打印我需要的值