LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 02-11-2005, 10:19 AM   #1
freeindy
Member
 
Registered: Nov 2002
Posts: 205

Rep: Reputation: 30
compiling simple c/c++ program but no good


Hi!

Now, i have looked all through this forum but i still canīt find solution. I'm using suse 9.1 with gcc ver 3.3.3
the code is:

Code:
#include <iostream>
using namespace std;

int main(void)
{
  unsigned int sum = 0;

  cout << "Summa:";
  cin >> sum;

  printf("sum::%d", sum);

  return 0;
}
and the error i get when i give the command gcc:

Quote:
/tmp/ccXRUxTx.o(.text+0x20): In function `main':
: undefined reference to `std::cout'
/tmp/ccXRUxTx.o(.text+0x25): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std:perator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccXRUxTx.o(.text+0x34): In function `main':
: undefined reference to `std::cin'
/tmp/ccXRUxTx.o(.text+0x39): In function `main':
: undefined reference to `std::basic_istream<char, std::char_traits<char> >:perator>>(unsigned&)'
/tmp/ccXRUxTx.o(.text+0x78): In function `__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init[in-charge]()'
/tmp/ccXRUxTx.o(.text+0xa7): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init [in-charge]()'
/tmp/ccXRUxTx.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
what's going on???

thanks for helping...

indy
 
Old 02-11-2005, 10:23 AM   #2
csfalcon
Member
 
Registered: Jun 2004
Location: MD
Distribution: Fedora Core
Posts: 269

Rep: Reputation: 31
gcc is the C compiler, try compiling with g++ instead.
 
Old 02-11-2005, 10:37 AM   #3
ChemicalBurn
LQ Newbie
 
Registered: Feb 2005
Posts: 28

Rep: Reputation: 15
Try also #include<cstdlib>
 
Old 02-12-2005, 12:38 PM   #4
freeindy
Member
 
Registered: Nov 2002
Posts: 205

Original Poster
Rep: Reputation: 30
ah. thanks csfalcon. I thought yoy used the same compiler... but now i get it.

cheers
indy
 
  


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
Compiling a simple C++ program for Windows Baix Programming 2 03-05-2005 08:17 PM
what is a good simple *cough* windows-like dialer program? visxera Linux - Newbie 2 03-25-2004 03:15 AM
Compiling a simple C++ program kbeaver Programming 27 02-06-2004 09:02 PM
good enough compiling program Derek-kun Linux - Newbie 1 09-22-2003 02:30 AM
Compiling a simple Mesa/GLUT program Bojdom Linux - Software 2 02-02-2003 05:19 PM


All times are GMT -5. The time now is 03:58 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration