包含标头的C++错误
C++ error with included headers
我在Linux操作系统(LUbuntu 15.05)上编译C++代码时遇到问题。
我在XUbuntu 14.10、Arch和Gentoo Linux上编译了相同的代码。一切都很好。现在我在家用台式电脑上安装LUbuntu,当我开始时,我会给出这个错误:
g++ -O2 -Wall -o main.o main.cpp
In file included from /usr/include/i386-linux-gnu/c++/5/bits/gthr-default.h:35:0,
from /usr/include/i386-linux-gnu/c++/5/bits/gthr.h:148,
from /usr/include/c++/5/ext/atomicity.h:35,
from /usr/include/c++/5/bits/ios_base.h:39,
from /usr/include/c++/5/ios:42,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from main.h:8,
from main.cpp:1:
/usr/include/pthread.h:1058:55: error: ‘_lock’ was not declared in this scope
extern int pthread_spin_trylock (pthread_spinlock_t *[_lock)
^
/usr/include/pthread.h:1058:54: error: expected ‘,’ or ‘...’ before ‘[’ token
extern int pthread_spin_trylock (pthread_spinlock_t *[_lock)
^
Makefile:30: recipe for target 'main.o' failed
make: *** [main.o] Error 1
这是我的主.h文件:
#ifndef MAIN_H
#define MAIN_H
#include <SDL/SDL.h>
#include <SDL/SDL_opengl.h>
#include <SDL/SDL_mixer.h>
#include <SDL/SDL_image.h>
#include <iostream>
#include <vector>
#endif // MAIN_H
我不知道该怎么办。我安装了build essential。请帮忙。
我在系统中查看了该文件,在第1058行附近,有一行:
extern int pthread_spin_trylock (pthread_spinlock_t *__lock)
奇怪。。。您的线路具有[
而不是预期的_
。。。
如果您查看_
和[
的ascii值,它们是:
_: 95 = 0x5F = 01011111
[: 91 = 0x5B = 01011011
看,只有一点不同。也许你的硬盘(sd卡?)是宇宙射线的受害者,但我会对硬盘和内存进行全面扫描,以防万一。
然后,您当然应该重新安装相关的软件包。我认为是libc6-dev
,而不是build-essential
,这是一个仅依赖的包,或者Debian称之为什么。
相关文章:
- 警告处理为错误这里有什么问题
- "error: no matching function for call to"构造函数错误
- boost::进程间消息队列引发错误
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- QT在错误的班级中寻找空位
- vector.resize()中的分配错误
- 代码在main()中运行,但在函数中出现错误
- 释放错误后堆使用
- (C++)分析树以计算返回错误值的简单算术表达式
- Project Euler问题4的错误解决方案
- 我的字符计数代码计算错误.为什么
- 从"int*"强制转换为"unsigned int"会丢失精度错误
- 尝试导入pybind-opencv模块时出现libgtk错误
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 在某些循环内使用vector.push_back时出现分段错误
- MSVC多行宏编译器错误
- 静态数据成员的问题-修复链接错误会导致编译器错误
- 为什么在运行时没有向我们提供有关分段错误的更多信息?
- 错误:未在此范围内声明'reverse'