久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 linux 下的 GCC 中使用 std::thread 的正確鏈接選項

What are the correct link options to use std::thread in GCC under linux?(在 linux 下的 GCC 中使用 std::thread 的正確鏈接選項是什么?)
本文介紹了在 linux 下的 GCC 中使用 std::thread 的正確鏈接選項是什么?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試將 std::thread 與 G++ 一起使用.這是我的測試代碼

Hi I am trying to use std::thread with G++. Here is my test code

#include <thread>
#include <iostream>

int main(int, char **){
    std::thread tt([](){ std::cout<<"Thread!"<<std::endl; });
    tt.join();
}

它可以編譯,但是當我嘗試運行它時,結果是:

It compiles, but when I try to run it the result is:

terminate called after throwing an instance of 'std::system_error'
  what():  Operation not permitted 
Aborted

我的編譯器版本:

$ g++ --version
g++ (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

我的測試代碼有什么問題?

What is wrong with my test code?

更新:我使用以下命令行來編譯和運行我的代碼.

UPDATE: I use the following command line to compile and run my code.

$ g++ -std=c++0x test.cpp
$ ./a.out

我試過了

$ g++ -std=c++0x -lpthread test.cpp
$ ./a.out

還是一樣.

推薦答案

我覺得在Linux上pthread是用來實現std::thread的,所以需要指定-pthread代碼>編譯器選項.

I think on Linux pthread is used to implement std::thread so you need to specify the -pthread compiler option.

因為這是一個鏈接選項,所以這個編譯器選項需要在源文件之后:

As this is a linking option, this compiler option need to be AFTER the source files:

$ g++ -std=c++0x test.cpp -pthread

這篇關于在 linux 下的 GCC 中使用 std::thread 的正確鏈接選項是什么?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

What is the fastest way to transpose a matrix in C++?(在 C++ 中轉置矩陣的最快方法是什么?)
Sorting zipped (locked) containers in C++ using boost or the STL(使用 boost 或 STL 在 C++ 中對壓縮(鎖定)容器進行排序)
Rotating a point about another point (2D)(圍繞另一個點旋轉一個點 (2D))
Image Processing: Algorithm Improvement for #39;Coca-Cola Can#39; Recognition(圖像處理:Coca-Cola Can 識別的算法改進)
How do I construct an ISO 8601 datetime in C++?(如何在 C++ 中構建 ISO 8601 日期時間?)
Sort list using STL sort function(使用 STL 排序功能對列表進行排序)
主站蜘蛛池模板: 伊人一区| 国产精品久久久久久久久久 | 欧美精品在线观看 | 日韩视频一级 | 欧美精品日韩精品 | 四虎在线观看 | 极品粉嫩国产48尤物在线播放 | 综合精品在线 | 天天草天天射 | 亚洲国产精品一区二区久久 | 在线视频亚洲 | 国产美女在线观看 | 亚洲欧美精品一区 | 久久精品网| 久久天天躁狠狠躁夜夜躁2014 | 久久久综合精品 | 中文在线一区二区 | 欧洲精品码一区二区三区免费看 | 亚洲第一在线 | 懂色av色香蕉一区二区蜜桃 | 久草在线 | 2019天天干天天操 | 一级午夜aaa免费看三区 | 日韩激情一区 | 中文字幕在线观看第一页 | 国产重口老太伦 | 亚洲h视频| 日本一区二区三区免费观看 | 免费激情| 一区二区高清在线观看 | 精品国产不卡一区二区三区 | 日韩精品免费播放 | 中文字幕一区在线观看视频 | 蜜桃视频一区二区三区 | 日韩精品在线看 | 污视频免费在线观看 | 天天操狠狠操 | 麻豆视频在线看 | 欧美日韩视频在线第一区 | 亚洲欧洲av在线 | 国产精品1区2区3区 欧美 中文字幕 |