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

标签 multithreading ubuntu c++11 gcc

所以我试图用一个线程运行一个简单的 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”添加到您的链接器选项(“链接器设置”→“其他链接器选项”)。

  • source (code blocks pthread 的第一个 Google 结果)
  • 关于multithreading - Ubuntu 14.04 中 Code::Blocks 上的 C++11,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28364754/

    相关文章:

    java - ThreadPoolExecutor - 即使没有线程空闲,也会更改池大小

    c# - INotifyPropertyChanged 和线程

    android - 安装 IONIC 时,设置了 ANDROID_HOME 变量但得到 'Failed to find ' ANDROID_HOME'环境变量'

    amazon-web-services - 如何使带有原始镜像的 EBS 卷可引导?

    java - 慢速多线程 java 应用程序 : is this due to access to static object?

    c# - 如何通过C# async/await为同步程序添加并发

    ubuntu - HID API 无法构建测试 gui

    c++ - Go 和 C++ 中的 vector 性能

    c++ - 如何生成第n个只有偶数位的数?

    c++ - 遍历 Base 类型的 vector 和/或从 base 派生的类型