Ubuntu 14.04 中 Code::Blocks 上的 C++11

C++11 on Code::Blocks in Ubuntu 14.04

所以我正在尝试 运行 一个简单的带线程的 hello world 程序。它是用于向您介绍线程的标准 hello world 程序。我在 Ubuntu 14.04 上使用 Code::Blocks IDE,我有 gcc 4.8.2。我使用 GCC 编译器来构建我的项目,我还检查了选项“让 g++ 遵循 C++11 ISO C++ 语言标准 [-std=c++11]”但是当我构建项目时我得到这个错误:

`terminate called after throwing an instance of 'std::system_error'
  what():  Enable multithreading to use std::thread: Operation not permitted`

我看到了告诉我在某处添加 -pthread-lthread 的解决方案,但我不知道在哪里写这个...有什么帮助吗?

将“-pthread”添加到您的链接器选项 ("Linker settings" → "Other linker options")。

  • sourcecode blocks pthread 的第一个 Google 结果)