Linux gnu ++ 11,在运行时获取“启用多线程以使用std :: thread:不允许操作”

时间:2014-11-27 04:55:24

标签: c++ linux makefile

我在我的项目中使用C ++ 11线程,在运行时我得到了以下内容:

"Enable multithreading to use std::thread: Operation not permitted"

阅读other posts我添加了-lpthread来链接pthreads库,但我仍然得到同样的错误......

编辑Snap

g++ -ggdb -ffunction-sections -O0 -lpthread -std=gnu++11   -DDEBUG  -c HID.cpp -o Debug/HID.o -MD -MF Debug/HID.dep

如何避免运行时异常?任何使用的鱼缸" -std = gnu ++ 11"而不是" -std = c ++ 11" ?

2 个答案:

答案 0 :(得分:0)

尝试使用-pthread而不是-lpthread。


答案 1 :(得分:0)

添加:-lpthread 在构建命令行上的源文件之后。