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与我交替着练,聊了几句话就多了起来,我对她说:"看到前面那俩教练没?老色鬼两枚!整天调戏女学员."她说:"还好啦,这毕竟是他们的乐趣所在,你不认为教练每 ...
随机推荐
- 每天5分钟玩转Docker
总结的这个八爪鱼图,不懂的时候随时翻翻书.....
- delphi Align属性
---------------------------------------------- -
- dcmtk dcmmkdir 使用帮助
例子: dcmmkdir --recurse --input-directory C:\TEMP DICOM --output-file C:\TEMP\DCMDIR --recurse 递归 -- ...
- 探讨android更新UI的几种方法(转)
作为IT新手,总以为只要有时间,有精力,什么东西都能做出来.这种念头我也有过,但很快就熄灭了,因为现实是残酷的,就算一开始的时间和精力非常充足,也会随着项目的推进而逐步消磨殆尽.我们会发现,自己越来越 ...
- http://www.cnblogs.com/jqyp/archive/2010/08/20/1805041.html
http://www.cnblogs.com/jqyp/archive/2010/08/20/1805041.html
- Eclipse通过Spket增加JQuery提示的方法
Eclipse通过Spket增加JQuery提示的方法 1.增加在线更新源:Help->Install New Software...->Add...->Name: "Sp ...
- Maven Web项目配置Mybatis出现SqlSessionFactory错误的解决方案
一.错误现象 严重: Context initialization failed org.springframework.beans.factory.BeanCreationException: Er ...
- IOS生成证书
1.生成本地签名文件, 点击此图标,选择证书助理,按照以下步骤生成签名文件,在生成证书时需要导入签名文件生成. 点击继续就能生成签名文件,保存次CSR文件. 2.生成证书 到下面这个页面选择证书的签名 ...
- JavaScript 数组的常用操作
JavaScript splice 方法 splice 方法用于插入.删除或替换数组的元素.语法如下: array_object.splice(start, num, element1, elemen ...
- SonarQube install on Kubernetes
Sonarqube搭建代码 apiVersion: extensions/v1beta1 kind: Deployment metadata: name: postgres labels: app: ...