LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 02-01-2009, 09:48 PM   #1
oinker
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)
why???

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;
return EXIT_SUCCESS;
}

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

Rep: Reputation: 23
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, 07:26 AM   #3
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154
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.)

But
http://www.linuxquestions.org/linux/...Ask_a_Question
http://linuxsilo.net/docs/smart-questions_en.html
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 08:54 AM.
 
  


Reply


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 07:16 PM
core-dumped dayalan_cse Programming 2 10-28-2007 04:32 AM
Message: "Abort (core dumped)", running Acrobat caesius_01 Linux - Software 1 04-22-2004 11:54 PM
urpmi - core dumped ashamril Mandriva 0 02-26-2004 09:41 PM
Core Dumped Nezar Linux - General 4 07-18-2001 03:29 AM


All times are GMT -5. The time now is 02:41 PM.

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