LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   compiling simple c/c++ program but no good (https://www.linuxquestions.org/questions/programming-9/compiling-simple-c-c-program-but-no-good-288928/)

freeindy 02-11-2005 09:19 AM

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::operator<< <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> >::operator>>(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

csfalcon 02-11-2005 09:23 AM

gcc is the C compiler, try compiling with g++ instead.

ChemicalBurn 02-11-2005 09:37 AM

Try also #include<cstdlib>

freeindy 02-12-2005 11:38 AM

ah. thanks csfalcon. I thought yoy used the same compiler... but now i get it.

cheers
indy


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