g++编译C++11遇到的问题:Enable multithreading to use std::thread: Operation not permitted
来源:互联网 发布:局域网禁用p2p软件 编辑:程序博客网 时间:2024/05/22 05:28
我安装了g++-4.8.5版本编译器,支持C++11,使用命令行g++-4.8 -std=c++11 -lpthread *.cpp编译后,得到的可执行文件在运行时遇到错误:
terminate called after throwing an instance of 'std::system_error'
what(): Enable multithreading to use std::thread: Operation not permittedAborted (core dumped)
在查了好久才发现问题,是编译器的问题,编译时要加上选项
-Wl,--no-as-needed
因为gcc4.6以后对于ld自动加上了as-needed选项。所以编译选项应该变成:
g++ -Wl,--no-as-needed -std=c++11 -pthread main.cpp
或者
g++ -std=c++11 -o main -Wl,--no-as-needed main.cpp -lpthread
这样就没有问题了!
如果是使用qtcreator的话,则需要在.pro文件加入:
LIBS += -pthreadQMAKE_CXXFLAGS += -pthreadQMAKE_CXXFLAGS += -std=c++11
参考文章:http://stackoverflow.com/questions/19463602/compiling-multithread-code-with-g
阅读全文
0 0
- g++编译C++11遇到的问题:Enable multithreading to use std::thread: Operation not permitted
- c++11编译错误 Enable multithreading to use std::thread: Operation not permitted
- Enable multithreading to use std::thread: Operation not permitted
- Enable multithreading to use std::thread: Operation not permitted
- c++ g++运行出现Enable multithreading to use std::thread: Operation not permitted解决
- Mac-Operation not permitted问题
- g++使用std::thread编译错误问题
- 使用Jedis遇到 ERR operation not permitted
- cvs移植的问题:setgid failed: Operation not permitted
- 关于Mac OS下的pip:Operation not permitted问题
- c++11 网络 Operation not permitted问题
- Mac OS X 11中的/usr/ 的“Operation not permitted”
- linux下编译c++程序遇到 error: ‘thread’ is not a member of ‘std’的错误
- Docker容器使用问题:Failed to get D-Bus connection: Operation not permitted
- setgid: Operation not permitted
- ptrace: Operation not permitted.
- Operation not permitted解决方法
- Operation not permitted
- rxjava的错误记录
- 安装mysql-connector-odbc-5.3.9时出现myodbc5s.dll 找不到
- Groovy入门教程
- Angularjs系列之作用域(scope)
- vue
- g++编译C++11遇到的问题:Enable multithreading to use std::thread: Operation not permitted
- Linux下模拟恶劣网络环境
- css实现高度动态变化自如 新手写着娱乐
- JZOJ1415. 单足跳(2017.8B组)
- 指向类成员变量的指针并非指针
- IPA重签名
- Python学习
- openstack storlet文档(二)
- QT定时器使用