gpt4 book ai didi

c++ - 无法解决 SIGABRT

转载 作者:行者123 更新时间:2023-11-30 02:35:30 25 4
gpt4 key购买 nike

我试图运行一个简单的代码,它编译但当我尝试运行它时我得到(核心转储)错误。于是用gdb查看错误是什么。

代码:

#include <thread>
#include <iostream>
#include <stdio.h>


void gerar()
{
printf("works\n");
}

int main()
{
std::thread oi(gerar);
printf("oi");

return 0;
}

dgb 消息:

Traceback (most recent call last):
File "/usr/share/gdb/auto-load/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19-gdb.py", line 63, in <module>
from libstdcxx.v6.printers import register_libstdcxx_printers
ImportError: No module named 'libstdcxx'
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff6fd6700 (LWP 4879)]
terminate called without an active exception

Program received signal SIGABRT, Aborted.
0x00007ffff7313cc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.

g++ 行:

g++ -c teste.cpp -pthread -std=c++11  
g++ teste.o -o teste -pthread -std=c++11

最佳答案

线程的析构函数:

If *this has an associated thread (joinable() == true), std::terminate() is called.

这是你的情况。

main 中调用 oi.join();

关于c++ - 无法解决 SIGABRT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33551953/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com