可以用clion的debug模式運行程序,可以在log窗口查看出錯位置,或者使用glog工具.
//在頭文件包含
#include <glog/logging.h>
//在main函數或者類的構造函數中添加
google::InitGoogleLogging("mytest"); //初始化 glog
google::InstallFailureSignalHandler();
在CMakeLists.txt中
target_link_libraries(executable glog)