G ++的Mutex和condition_variable编译错误

时间:2019-04-02 12:22:39

标签: c++ linux multithreading g++ mutex

我有以下代码:

$('#Amsterdam').on('mouseover', function(){chart.render();})
$('#Rotterdam').on('mouseover', function(){chart2.render();})
$('#Eindhoven').on('mouseover', function(){chart3.render();})
$('#Maastricht').on('mouseover', function(){chart4.render();})
$('#Groningen').on('mouseover', function(){chart5.render();})

在Windows上编译时,我没有问题,但是在Unix上编译时就可以了。 我首先尝试使用以下命令进行编译: #include <vector> #include <string> #include <mutex> #include <queue> std::mutex queue_mutex; std::condition_variable condition; int main(int argc, char** argv) { return 0; }

但是出现以下错误:

g++ -O3 -Wall tester.cpp -lpthread -o tester

所以我尝试使用 In file included from /usr/include/c++/4.8/mutex:35:0, from gamytester.cpp:7: /usr/include/c++/4.8/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options. #error This file requires compiler and library support for the \ ^ gamytester.cpp:10:2: error: ‘mutex’ in namespace ‘std’ does not name a type std::mutex queue_mutex_; ^ gamytester.cpp:11:2: error: ‘condition_variable’ in namespace ‘std’ does not name a type std::condition_variable condition_;

那仍然导致我另一个错误:

g++ -O3 -Wall -std=c++11 tester.cpp -lpthread -o tester

我正在运行openSUSE 13.02,并且具有g ++编译器版本4.8.3。

有人知道如何帮助我吗?

0 个答案:

没有答案