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与我交替着练,聊了几句话就多了起来,我对她说:"看到前面那俩教练没?老色鬼两枚!整天调戏女学员."她说:"还好啦,这毕竟是他们的乐趣所在,你不认为教练每 ...
随机推荐
- 一些关于VC++开发的笔记
通常程序卡住了,主要有双方面的可能: (1)死循环了 (2)死锁了 要确定是否是死循环.能够通过调试器(经常使用Windbg)查看线程执行时间,假设隔了一段会儿两次查看的执行时间有非常大区别,那么非常 ...
- hdr rt format对颜色的影响
我刚刚终于理解为什么rendertarget的format对颜色的影响为什么那么大了 r8g8b8a8 这种会有band artifacts rgbafloat 这种浮点rt 的色带变化更为连贯(R ...
- Scriptable render pipeline unity
https://www.youtube.com/watch?v=zbjkEQMEShM LWRP https://blogs.unity3d.com/cn/2018/02/21/the-lightwe ...
- 模糊搜索:concat各种函数详解、like操作符、通配符
if(StringUtils.isNotBlank(queryBean.getConditions())){ hqlBuilder.addWhereClause(" concat(this. ...
- jquery 获取父窗口的元素、父窗口、子窗口
一.获取父窗口元素: $("#父窗口元素ID",window.parent.document):对应javascript版本为window.parent.document.getE ...
- Linux 调度器发展简述
引言 进程调度是操作系统的核心功能.调度器只是是调度过程中的一部分,进程调度是非常复杂的过程,需要多个系统协同工作完成.本文所关注的仅为调度器,它的主要工作是在所有 RUNNING 进程中选择最合适的 ...
- Apache2.4 与 php7.1.6的链接
首先Apache已经安装成功,在浏览器中能够打开再下载php 我的Apache安装版本为Apache2.4.26 x64 vc14 所以我php也应该是vc14编译的 php下载地址为 http:// ...
- 登录Tomcat控制台
在http://localhost:8080界面中,右上角有三个按纽对应着三个控制台:Server Status控制台,Manager App控制台和Host Manager控制台.Server St ...
- Python Pygal绘制世界人口地图
数据集可在 https://datahub.io/JohnSnowLabs/population-figures-by-country 下载 #coding=utf-8 import json fro ...
- linux经常使用文字处理命令总结
linux grep命令 作用 Linux系统中grep命令是一种强大的文本搜索工具,它能使用正則表達式搜索文本,并把匹 配的行打印出来.grep全称是Global Regular Expressio ...