首页 > 系统服务 > 详细

linux 学习

时间:2015-07-18 12:25:21      阅读:262      评论:0      收藏:0      [点我收藏+]

最近在学习linux,用的是VMware player 下的Ubuntu 14.04.初试一段小代码test.cpp,然后编译 g++ test.cpp  之后出来的结果是我需要设置-std=c++11

或者-std=gnu++11选项,后来采用 g++ -std=c++11 test.cpp 进行编译,但是编译是通过了,接着问题又来了,运行./test 出现了

terminate called after throwing an instance of ‘std::system_error‘
what(): Enable multithreading to use std::thread: Operation not permitted Aborted


这样一堆问题,最后不停滴百度,有人说用g++ -o test test.cpp -pthread -std=c++11 来进行编译,试过之后,发现这样编译后生成的文件是可执行的。即编译和链接时都指定-pthread

#include <thread>
#include <iostream>
void my_thread()
{
puts("hello, world");
}

int main(int argc, char *argv[])
{
std::thread t(my_thread);
t.join();

system("pause");
return 0;
}

linux 学习

原文:http://www.cnblogs.com/youyunjingfan/p/4656469.html

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