LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Simple C++ code won't compile on 2 out of 3 systems (https://www.linuxquestions.org/questions/programming-9/simple-c-code-wont-compile-on-2-out-of-3-systems-389574/)

JimChristiansen 12-05-2005 03:54 PM

Simple C++ code won't compile on 2 out of 3 systems
 
I need some help to sort out why only my old 30 Fedora 2 school boxes will compile:

#include <iostream>
using namespace std;
int main( )
{
cout << "Hello World!!";
}


While my two thin servers running Fedora 3 and 4 serving 100 clients fails to compile... with:

[jim@adminmrc Programming]$ gcc -Wall -o dallasisspecial dallas.cpp
/tmp/ccAdWbGa.o(.text+0xd): In function `std::__verify_grouping(char const*, unsigned int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::size() const'
/tmp/ccAdWbGa.o(.text+0x60): In function `std::__verify_grouping(char const*, unsigned int,
.
.
.
: undefined reference to `std::cout'
/tmp/ccAdWbGa.o(.text+0x126): 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/ccAdWbGa.o(.text+0x152): In function `__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init()'
/tmp/ccAdWbGa.o(.text+0x181): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccAdWbGa.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

Thanks, Jim

Hivemind 12-05-2005 04:01 PM

Use g++ to compile C++-programs, gcc is for C-programs.

Mega Man X 12-05-2005 04:31 PM

Your main method expects an Integer as return value too. Don't forget to have a return 0; or something at the end.

jtshaw 12-05-2005 07:13 PM

Just in case you were wondering

g++ = gcc -lstdc++

JimChristiansen 12-06-2005 04:52 PM

Thanks!
 
Thanks!

OHH!!! Just too many thing going on I guess to think straight.


All times are GMT -5. The time now is 05:19 AM.