Linux C/C++ 编译、调试问题汇总
2021/10/28 7:13:49
本文主要是介绍Linux C/C++ 编译、调试问题汇总,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
环境说明
Ubuntu版本: 14.04.1 x86_64 LTS
g++ 版本: 4.8.4
问题
terminate called after throwing an instance of 'std::system_error'
g++编译cpp源码后,运行程序出现错误提示:“terminate called after throwing an instance of 'std::system_error'”
$ gcc -std=C++11 test.cpp -o test $ ./test terminate called after throwing an instance of 'std::system_error' what(): Enable multithreading to use std::thread: Operation not permitted 已放弃 (核心已转储)
问题原因:使用了C++ thread,但是没有链接pthread线程库。
解决办法:修改编译命令,链接pthread库
$ g++ -std=C++11 test.cpp -o test -lpthread // 或者 $ g++ -std=C++11 test.cpp -o test -pthread
注意:老版本g++编译器,需要同时指定使用的C++标准,因为老版本编译器默认不是支持C++11的,而thread类是C++11之后引入的内容。
这篇关于Linux C/C++ 编译、调试问题汇总的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-09-11Linux部署Scrapy学习:入门级指南
- 2024-09-11Linux部署Scrapy:入门级指南
- 2024-08-21【Linux】分区向左扩容的方法
- 2024-08-21【Linux】gnome桌面环境切换KDE Plasma
- 2024-08-19如何安装 VMware Tools (macOS, Linux, Windows)
- 2024-08-15Linux部署Scrapy教程:入门级指南
- 2024-07-29linux命令行下好用的性能监控工具atop
- 2024-07-04Linux系统上离线升级SSH服务的具体操作步骤-icode9专业技术文章分享
- 2024-06-0600-macOS和Linux安装和管理多个Python版本
- 2024-03-30[译]漫画SELinux概念