1,105,254 Community Members

eror compile c++ code in cygwin

Member Avatar
TarekSliem
Newbie Poster
3 posts since Apr 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

The problem that i couldn't know if the mistake from the code or from the compiler?
i have been setup cygwin.........as starting to learn Linux and into it
as a start to learn c++
i want to compile a (hello world) code
==================

#include<iostream.h>
void main()
{
cout<<"helloworld";

}

===================
but when i try to compile it with g++

i received the following message :-
=+=+==+=+==+=+==+=+==+=+==+=+==+=+==+=+==+=+=
=+=+==+=+==+=+=+==+=+==+=+==+=+==+==+=+==+=+=
$ gcc hello_world.cpp

In file included from /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/backward/iostream.h:31,

from hello_world.cpp:1:
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/backward/backward_warning.h:32:2: warning: #w
arning This file includes at least one deprecated or antiquated header. Please consider usi
ng one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include su
bstituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of t
he deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -luser32
collect2: ld returned 1 exit status
=+=+==+=+==+=+==+=+==+=+==+=+==+=+==+=+=
=+=+==+=+==+=+==+=+==+=+==+=+==+=+==+=+=
so please see it quickly and reply me here
or more faster by e-mail

<snip email>

----------------------------------------------------------
and thanks for your accurate .

Member Avatar
Nick Evan
Industrious Poster
4,827 posts since Oct 2006
Reputation Points: 4,005 [?]
Q&As Helped to Solve: 560 [?]
Skill Endorsements: 30 [?]
Team Colleague
Featured
 
1
 

So why not do what the message says? Change iostream.h to iostream. Also don't forget that "cout" is from the std:: namespace, so either use std::cout or put a using namespace std; at the beginning of your code.

also read:
Void main
Code tags

Member Avatar
TarekSliem
Newbie Poster
3 posts since Apr 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

thanks........in real
i have been do that and it dosn't work......but any way i think that i setup cgwin with some error so i'll delete it then start with more simple IDE visual studio 2005
.........................
but any way i hope to be friends
c u .....
bye

Member Avatar
mvmalderen
Nearly a Posting Maven
2,370 posts since Feb 2009
Reputation Points: 2,071 [?]
Q&As Helped to Solve: 282 [?]
Skill Endorsements: 40 [?]
 
0
 

Yes, change #include <iostream.h> to #include <iostream> and put the instruction using namespace at the top of your code or use the std:: specifier for each object (in namespace std) you want to use :) ...

By the way: avoid using void main it's unnecessary look here: http://cppdb.blogspot.com/ ...

Member Avatar
Absaar
Newbie Poster
6 posts since Apr 2009
Reputation Points: -6 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
-1
 

#include<iostream>
using namespce std;
void main()
{
cout<<"helloworld";

}
//try this it will work

Member Avatar
TarekSliem
Newbie Poster
3 posts since Apr 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

thanks all friend for your precious time

Member Avatar
Surojit
Newbie Poster
1 post since Jun 2009
Reputation Points: -4 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
-2
 

Hi You can do the following
i) Compile
$ gcc -Wno-deprecated hello_world.cpp

ii) Do the following changes in you code
#include<iostream>

using namespace std;

void main()
{
cout<<"helloworld";

}


The problem that i couldn't know if the mistake from the code or from the compiler?
i have been setup cygwin.........as starting to learn Linux and into it
as a start to learn c++
i want to compile a (hello world) code
==================

#include<iostream.h>
void main()
{
cout<<"helloworld";

}

===================
but when i try to compile it with g++

i received the following message :-
=+=+==+=+==+=+==+=+==+=+==+=+==+=+==+=+==+=+=
=+=+==+=+==+=+=+==+=+==+=+==+=+==+==+=+==+=+=
$ gcc hello_world.cpp

In file included from /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/backward/iostream.h:31,

from hello_world.cpp:1:
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/backward/backward_warning.h:32:2: warning: #w
arning This file includes at least one deprecated or antiquated header. Please consider usi
ng one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include su
bstituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of t
he deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -luser32
collect2: ld returned 1 exit status
=+=+==+=+==+=+==+=+==+=+==+=+==+=+==+=+=
=+=+==+=+==+=+==+=+==+=+==+=+==+=+==+=+=
so please see it quickly and reply me here
or more faster by e-mail

<snip email>

----------------------------------------------------------
and thanks for your accurate .

Member Avatar
Stefano Mtangoo
Senior Poster
3,713 posts since Jun 2007
Reputation Points: 441 [?]
Q&As Helped to Solve: 394 [?]
Skill Endorsements: 2 [?]
 
0
 

Also just an advice,
why not use codeblocks instead of hard compiling hand to hand?
It is here:
www.codeblocks.org
Just MHO

Member Avatar
mvmalderen
Nearly a Posting Maven
2,370 posts since Feb 2009
Reputation Points: 2,071 [?]
Q&As Helped to Solve: 282 [?]
Skill Endorsements: 40 [?]
 
0
 

Another advice: I think the OP's problem is already solved, BTW did someone actually notice that this thread is more than one month old?

Member Avatar
Stefano Mtangoo
Senior Poster
3,713 posts since Jun 2007
Reputation Points: 441 [?]
Q&As Helped to Solve: 394 [?]
Skill Endorsements: 2 [?]
 
0
 

I didn't :)

Member Avatar
ankitloud
Newbie Poster
1 post since Apr 2008
Reputation Points: -6 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
-2
 

don't use #include<iostream.h>
use #include<iostream>

old days ppl used .h in c++ now only iostream

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article