简体   繁体   English

为在Visual Studio中工作的C ++程序而在Linux中弃用了Abort Core

[英]Abort Core Dumped in linux for a C++ progam that works in Visual Studio

I have a C++ project that was built and runs in Visual Studio. 我有一个在Visual Studio中构建并运行的C ++项目。 When I try to run it in unix, it gives me Abort (Core Dumped) 当我尝试在Unix中运行它时,它给了我Abort(Core Dumped)

I am using the g++ version 3.2.2 How do i Fix this program ? 我正在使用g ++版本3.2.2如何修复此程序? It needs to run in linux. 它需要在linux中运行。

First step is to learn how to use gdb or any of the other excellent debuggers for Linux. 第一步是学习如何使用gdb或其他任何用于Linux的优秀调试器。

That should be able to tell you exactly which source line caused the problem. 那应该能够告诉您确切的问题源线。 Then work back from there. 然后从那里回来。

Other than that, we can't really help without seeing that source code. 除此之外,如果没有看到该源代码,我们将无济于事。 Psychic debugging, whilst useful, is not a highly developed field of endeavour :-) 心理调试虽然有用,但并不是一个高度发达的领域:-)

@All Thanks a lot for your responses.I really appreciate it @All非​​常感谢您的回复。我非常感谢

My program worked with g++ 4.2.3. 我的程序使用g ++ 4.2.3。 It was aborting with g++ 3.2.2. 它在g ++ 3.2.2中中止。

The code that gave me the correct output in visual studio was 在Visual Studio中为我提供正确输出的代码是

foundOpen = inStr.find("(");
foundClose = inStr.find(")");
string inGate;
inGate = inStr.substr(++foundOpen,foundClose-foundOpen);

But using g++, I had to make a small change to the substr function. 但是使用g ++时,我不得不对substr函数进行一些小的更改。

foundOpen = inStr.find("(");
foundClose = inStr.find(")");
string inGate;
inGate = inStr.substr(++foundOpen,foundClose-foundOpen-1);

I am also a beginner to using linux and don't know how to use gdb. 我也是使用linux的初学者,不知道如何使用gdb。 Are there any good tutorials to learn gdb? 有什么好的教程可以学习gdb吗?

I'll take a flying guess: your program uses ' getch() ' and you found the function in the library -lcurses or -lncurses and are using that library, but your program crashes as you said. 我要飞的猜测:你的程序使用“ getch() ”,你发现在库中的函数-lcurses-lncurses和正在使用的库,但你的程序崩溃,你说。

The trouble is, that function requires a certain amount of setup to work - unlike the similarly named but rather different function that is available on Windows. 麻烦的是,该功能需要一定数量的设置才能起作用-与Windows上名称相似但功能不同的功能不同。

Welcome to the real world - different platforms have different functions in the standard APIs; 欢迎来到现实世界-不同的平台在标准API中具有不同的功能; sometimes, two platforms have a function with the same name but different meanings. 有时,两个平台具有相同名称但含义不同的功能。

Another wild guess: boolean initialization , we got bit by this one. 另一个疯狂的猜测: 布尔值初始化 ,我们被这一点所困扰。 The boolean was initialized automatically using VC++2003 but on Linux it was not (thus either true or false, flip a coin...). 布尔值是使用VC ++ 2003自动初始化的,但在Linux上不是(因此,对或错,掷硬币...)。

Took a while to debug since in our case it did not crash and was intermittent. 花费了一段时间进行调试,因为在我们的案例中它没有崩溃并且是间歇性的。 I wanted to slap the programmer on the head for not initializing his variable! 我想拍打程序员,因为他没有初始化他的变量!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM