2016-01-11 51 views
0

我在編譯Linux操作系統(LUbuntu 15.05)上的C++代碼時遇到了問題。包含的標題C++錯誤

我在XUbuntu 14.10,Arch和Gentoo Linux上編譯的代碼相同。一切都很好。現在,我在回家的臺式PC安裝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 

這是我main.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。 請幫忙。

+2

好吧,那不是C++語法。如果你有權訪問該文件,從''('pthread_spinlock_t * [_ lock)' – xinaiz

回答

1

我已經看過該文件在我的系統,並非常接近行號1058,有這樣一行:

extern int pthread_spin_trylock (pthread_spinlock_t *__lock) 

奇怪...您的線路有[,而不是預期_ .. 。

如果你看看_[的ASCII值,它們分別是:

_: 95 = 0x5F = 01011111 
[: 91 = 0x5B = 01011011 

看到的,只是一個DIFF位erence。也許你的硬盤(sd-card?)是cosmic ray的受害者,但我會對硬盤和內存進行全面掃描,以防萬一。

然後,當然,您應該重新安裝相關的軟件包。我認爲它是libc6-dev,而不是build-essential,這是一個僅依賴項的包,或者任何Debian所稱的包。