DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 26th July 2008
Gates Gates is offline
New User
 
Join Date: Jul 2008
Posts: 4
Default c++ compiling hello world

As you can guess i am totally new in this theme. I do not understand error message, so i am asking for your help. Why can't i compile this program:
Code:
#include <iostream.h>

int main()
{
  cout << "Hello World!\n";
  return 0;
}
Error:
Code:
%gcc n01-hello.cpp
In file included from /usr/include/c++/3.4/backward/iostream.h:31,
                 from n01-hello.cpp:1:
/usr/include/c++/3.4/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
n01-hello.cpp:7:2: warning: no newline at end of file
/var/tmp//ccLD53t1.o(.text+0xd): In function `std::__verify_grouping(char const*, unsigned int, std::string const&)':
: undefined reference to `std::string::size() const'
/var/tmp//ccLD53t1.o(.text+0x60): In function `std::__verify_grouping(char const*, unsigned int, std::string const&)':
: undefined reference to `std::string::operator[](unsigned int) const'
/var/tmp//ccLD53t1.o(.text+0x9d): In function `std::__verify_grouping(char const*, unsigned int, std::string const&)':
: undefined reference to `std::string::operator[](unsigned int) const'
/var/tmp//ccLD53t1.o(.text+0xc8): In function `std::__verify_grouping(char const*, unsigned int, std::string const&)':
: undefined reference to `std::string::operator[](unsigned int) const'
/var/tmp//ccLD53t1.o(.text+0x121): In function `main':
: undefined reference to `std::cout'
/var/tmp//ccLD53t1.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*)'
/var/tmp//ccLD53t1.o(.text+0x152): In function `__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init()'
/var/tmp//ccLD53t1.o(.text+0x183): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init()'
/var/tmp//ccLD53t1.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
%
Reply With Quote
  #2   (View Single Post)  
Old 26th July 2008
ocicat ocicat is offline
Administrator
 
Join Date: Apr 2008
Posts: 3,318
Default

Quote:
Originally Posted by Gates View Post
%gcc n01-hello.cpp
For compiling C++ code, use g++, not gcc.
Reply With Quote
  #3   (View Single Post)  
Old 26th July 2008
Gates Gates is offline
New User
 
Join Date: Jul 2008
Posts: 4
Default

Uhh. Thanks!
Reply With Quote
  #4   (View Single Post)  
Old 26th July 2008
18Googol2's Avatar
18Googol2 18Googol2 is offline
Real Name: whoami
Spam Deminer
 
Join Date: Apr 2008
Location: pwd
Posts: 283
Default

I personally use c++, save a bit typing
Reply With Quote
Reply

Tags
g++, gcc

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with installing world sniper007 FreeBSD Installation and Upgrading 1 17th April 2009 10:33 AM
Make world failure disappearedng FreeBSD General 1 16th January 2009 12:04 PM
Error building world 6.3 -> 6.4 chavez243 FreeBSD Installation and Upgrading 1 7th January 2009 02:31 PM
Newbie - adventure in gateway world Johnny2Bad FreeBSD General 1 17th May 2008 10:22 AM


All times are GMT. The time now is 03:51 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick