Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-01-2009, 08:48 PM   #1
LQ Newbie
Registered: Feb 2009
Posts: 3

Rep: Reputation: 0
Cannot compile with g++ (Abort: core dumped)

when i try to compile my code i get an error.
I type:
g++ add.cpp -o add
and I get the following message after quite some time:
Abort (core dumped)

here is my code:

#include <cstdlib>
#include <iostream>
int main(){
int x, y;
std::cout << "enter thy numbers: \n" ;
std::cin >> x >> y;
int sum = x + y;
std::cout << "sum is: \n" << sum << std::endl;

Can someone help me out pleaseee!
Old 02-02-2009, 04:24 AM   #2
Registered: Nov 2008
Location: Washington state, USA
Distribution: NetBSD, FreeBSD, OpenBSD, OpenSolaris, Slackware, Salix, FreeSlack, Android
Posts: 262

Rep: Reputation: 24
I am unsure why you include cstdlib in a C++ program (unless you know you included it right.) All I can say is sometimes libraries assume you are using another libary or doing something in a specific way, and sometimes they have bugs, but it does not look like this should happen (though I briefly checked Dr. Stroustrup's book from 2000 and the different things he says about endl slightly puzzles me.) It sounds like there could just be something else wrong on your system. You could try doing 'int sum' and 'sum=x+y' separately, but it should probably work anyway. I have not used such return flags as yo do, but I have seen them in working code, though I did not read it all....
Old 02-02-2009, 06:26 AM   #3
LQ 5k Club
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016 CentOS6.9 CentOS7.3 + 50+ other Linux OS, for test only.
Posts: 16,706

Rep: Reputation: 3294Reputation: 3294Reputation: 3294Reputation: 3294Reputation: 3294Reputation: 3294Reputation: 3294Reputation: 3294Reputation: 3294Reputation: 3294Reputation: 3294
Welcome to LQ.

Nice little "addition machine".
The code works fine on a couple of my systems.
( doesn't work without '#include <cstdlib>' ,
but '#include <stdlib.h>' instead works fine too.)

It's a good idea to tell, which Linux + "Linux version"
you are using, e.g Fedora 10, Ubuntu 8.10, RH EL 5,
every time a question is asked. ( And compiler version. )
Or add it to your Profile in "Edit Profile" here at LQ.

Last edited by knudfl; 02-02-2009 at 07:54 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
core dumped......! vipul jain Programming 2 11-07-2008 06:16 PM
core-dumped dayalan_cse Programming 2 10-28-2007 03:32 AM
Message: "Abort (core dumped)", running Acrobat caesius_01 Linux - Software 1 04-22-2004 10:54 PM
urpmi - core dumped ashamril Mandriva 0 02-26-2004 08:41 PM
Core Dumped Nezar Linux - General 4 07-18-2001 02:29 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:42 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration