Enable multithreading to use std::thread: Operation not permitted问题解决
在用g++ 4.8.2编译C++11的线程代码后,运行时遇到了如下报错:
terminate called after throwing an instance of 'std::system_error'
what(): Enable multithreading to use std::thread: Operation not permitted
Aborted (core dumped)
我们先看一下代码:
#include <boost/atomic.hpp>
#include <thread>
#include <iostream> boost::atomic<int> a{}; void thread()
{
++a;
} int main()
{
std::thread t1{thread};
std::thread t2{thread};
t1.join();
t2.join();
std::cout << a << '\n';
}
之前用的编译命令为:
/opt/compiler/gcc-4.8.2/bin/g++ test.cpp -I ./boost/include -std=c++11
需要改为:
/opt/compiler/gcc-4.8.2/bin/g++ test.cpp -I ./boost/include -std=c++11 -lpthread -Wl,--no-as-needed
这样运行就不会报错了。
本文参考自:https://stackoverflow.com/questions/19463602/compiling-multithread-code-with-g#
Enable multithreading to use std::thread: Operation not permitted问题解决的更多相关文章
- linux每日一练:Enable multithreading to use std::thread: Operation not permitted问题解决
linux每日一练:Enable multithreading to use std::thread: Operation not permitted问题解决 在linux在需要使用c++11时会遇到 ...
- "npm ERR! Error: EPERM: operation not permitted"问题解决
在基于macaca进行自动化测试的时候,遇到如下问题: E:\AutoTest\Macaca\LocalTEST\macaca-test-sample\macaca-test>macaca do ...
- C++ std::thread
std::thread Defined in header class thread The class thread represents a single thread of execution. ...
- C++11 并发指南------std::thread 详解
参考: https://github.com/forhappy/Cplusplus-Concurrency-In-Practice/blob/master/zh/chapter3-Thread/Int ...
- std::thread使用
本文将从以下三个部分介绍C++11标准中的thread类,本文主要内容为: 启动新线程 等待线程与分离线程 线程唯一标识符 1.启动线程 线程再std::threada对象创建时启动.最简单的情况下, ...
- std::thread
std::shared_ptr<std::thread> m_spThread; m_spThread.reset(new std::thread(std::bind(&GameS ...
- 用std::thread替换实现boost::thread_group
thread_group是boost库中的线程池类,内部使用的是boost::thread. 随着C++ 11标准的制定和各大编译器的新版本的推出(其实主要是VS2012的推出啦……),本着能用标准库 ...
- C++ 11 笔记 (五) : std::thread
这真是一个巨大的话题.我猜记录完善绝B需要一本书的容量. 所以..我只是略有了解,等以后用的深入了再慢慢补充吧. C++写多线程真是一个痛苦的事情,当初用过C语言的CreateThread,见过boo ...
- Cocos2dx 3.0 过渡篇(二十六)C++11多线程std::thread的简单使用(上)
昨天练车时有一MM与我交替着练,聊了几句话就多了起来,我对她说:"看到前面那俩教练没?老色鬼两枚!整天调戏女学员."她说:"还好啦,这毕竟是他们的乐趣所在,你不认为教练每 ...
随机推荐
- 【LaTeX】E喵的LaTeX新手入门教程(4)图表
这里说的不是用LaTeX画图,而是插入已经画好的图片..想看画图可以把滚动条拉到底.前情回顾[LaTeX]E喵的LaTeX新手入门教程(1)准备篇 [LaTeX]E喵的LaTeX新手入门教程(2)基础 ...
- logback中打印sql语句
To log SQL statements for particular mybatis mapper set DEBUG (TRACE to see query parameters and res ...
- 【Javascript】如何实现点的wave效果 && sinewave效果
参考资料: sinewave效果:http://www.oneapm.com/ci/docker.html?utm_source=BaiduPaid&utm_medium=cpc&ut ...
- 教你用webgl快速创建一个小世界
收录待用,修改转载已取得腾讯云授权 作者:TAT.vorshen Webgl的魅力在于可以创造一个自己的3D世界,但相比较canvas2D来说,除了物体的移动旋转变换完全依赖矩阵增加了复杂度,就连生成 ...
- UVA270-Lining Up
斜率斜率斜率......... #include<iostream> #include<cstdio> #include<algorithm> #include&l ...
- 集合系列之fail-fast 与fail-safe 区别
一:快速失败(fail—fast) 在用迭代器遍历一个集合对象时,如果遍历过程中对集合对象的内容进行了修改(增加.删除.修改),则会抛出Concurrent Modification Exceptio ...
- Git学习笔记二--工作区和暂存区
Git和其他版本控制系统如SVN的一个不同之处就是有暂存区的概念. 简单理解: 我们使用mkdir Git在d盘下创建的文件夹,就是工作区,我们编辑readme.txt文件就是在工作区下完成的: gi ...
- 【转】Socket状态变迁图
转自:http://www.cnblogs.com/ILove/archive/2008/12/08/1350430.html 服务端,端口的状态变化 先在本机(IP地址为:192.168.1.1 ...
- ES6 对象扩展
1.属性和变量可以简写 let birth = '2000/01/01'; const Person = { name: '张三', //等同于birth: birth birth, // 等同于he ...
- python基础教程_学习笔记12:充电时刻——模块
充电时刻--模块 python的标准安装包含一组模块,称为标准库. 模块 >>> import math >>> math.sin(0) 0.0 模块是程序 不论什 ...