gpt4 book ai didi

C++程序启动并挂起而没有错误

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:26:19 25 4
gpt4 key购买 nike

习惯了 IDE 牵着你的手,我被困住了,不知道从哪里开始寻找解决方案。我什至不知道这种类型的问题叫什么...该程序使用 Xcode 成功运行,但在 Raspberry Pi 上编译和运行时,它编译成功并启动但没有给出任何输出或错误。

我已经尝试删除除标题和主要内容之外的所有内容:

std::cout << "Test" << std::endl;

仍然没有输出。编译使用:

g++-4.7 -I include -I include/interface -I /usr/local/ssl/include -I /home/pi/gateway/mysql-connector-c++-1.1.5 -I /home/pi/gateway/mysql-connector-c++-1.1.5/cppconn -I /home/pi/gateway/mysql-connector-c++-1.1.5/driver -l mysqlcppconn -lwiringPi -lpthread -ldl -L/home/pi/gateway/live -std=c++11 -D PRODUCTION -o Gateway main.cpp src/*.cpp /usr/local/ssl/lib/libcrypto.a /usr/local/ssl/lib/libssl.a;

3.6mb of memory is being used but CPU usage is 0%.

Edit:By pure luck I found the problem, a static member object with a waiting callback in its constructor included through one of the headers. The question remains, where would one start troubleshooting? I'd rather not rely on luck next time! Commenting out one header at a time would result in all sorts of errors, so would removing compilation flags. I've included the minimal amount of code compiling successfully using the flags above.

#include <iostream>
#include <stdlib.h>
#include <unistd.h>
#include <csignal>
#include <cstring>
#include <fstream>
#include "lightdevice.h"
#include "websocketserver.h"
#include "errorlog.h"
#include "debuglog.h"

int main (int argc, char *argv[])
{
std::cout << "Why is this not printing?" << std::endl;
return EXIT_SUCCESS;
}

最佳答案

在调试器中运行时,可以检查这些线程。查看调用堆栈并找到正在创建的对象。

关于C++程序启动并挂起而没有错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34426555/

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