首页 > 编程语言 > 详细

g++编译C++11/C++0x遇到的问题

时间:2014-10-09 01:07:27      阅读:222      评论:0      收藏:0      [点我收藏+]

在看《Cplusplus Concurrency In Action Practical Multithreading》时遇到第一个例子:

#include<iostream>
#include<thread>
void hello()
{
	std::cout<<"hello concurrent world\n";
}
int main()
{
	std::thread t(hello);
	t.join();
}

我安装了g++-4.8版本编译器,支持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 permitted

Aborted (core dumped)

在查了好久才发现问题,是编译器的问题,编译时要加上选项

-Wl,--no-as-needed
参考这里:http://stackoverflow.com/questions/19463602/compiling-multithread-code-with-g

g++编译C++11/C++0x遇到的问题

原文:http://blog.csdn.net/kangroger/article/details/39901601

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!