473,383 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

iostream under Cygwin

I have installed the Cygwin package under WinXP. I am trying to insure
that I have a reasonable development environment, and that things are
working properly, by trying to compile and run the following classic
program.

$ cat hellow.cpp
#include <iostream>

int main (int argc, char *argv[]) {
cout << "Hello, world" << endl;
}
However, when I try to compile, I get

$ g++ hellow.cpp
hellow.cpp: In function `int main(int, char**)':
hellow.cpp:4: error: `cout' undeclared (first use this function)
hellow.cpp:4: error: (Each undeclared identifier is reported only
once for each function it appears in.)
hellow.cpp:4: error: `endl' undeclared (first use this function)

In trying to get more comprehensive infomation, I tried the command
shown below with its output.

If I'm doing something pathetically stupid, do not hesitate to tell me
so --- I've been doing Java for a few years, and I may have forgotten
something really important. :-) Thanks in advance for any help.

- Jerry Oberle
$ g++ -v -H hellow.cpp
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/specs
Configured with: /gcc/gcc-3.3.3-3/configure --verbose --prefix=/usr
--exec-prefi
x=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib
--mandir=/usr/s
hare/man --infodir=/usr/share/info
--enable-languages=c,ada,c++,d,f77,java,objc,
pascal --enable-nls --without-included-gettext --enable-libgcj
--with-system-zli
b --enable-interpreter --enable-threads=posix --enable-java-gc=boehm
--enable-sj
lj-exceptions --disable-version-specific-runtime-libs
--disable-win32-registry
Thread model: posix
gcc version 3.3.3 (cygwin special)
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/cc1plus.exe -quiet -v
-D__GNUC__=3 -D__GN
UC_MINOR__=3 -D__GNUC_PATCHLEVEL__=3 -H -D__CYGWIN32__ -D__CYGWIN__
-Dunix -D__u
nix__ -D__unix -idirafter
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/../../../../incl
ude/w32api -idirafter
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/../../../../i686-pc-
cygwin/lib/../../include/w32api hellow.cpp -D__GNUG__=3 -quiet
-dumpbase hellow.
cpp -auxbase hellow -version -o /tmp/ccny7uu0.s
GNU C++ version 3.3.3 (cygwin special) (i686-pc-cygwin)
compiled by GNU C version 3.3.3 (cygwin special).
GGC heuristics: --param ggc-min-expand=99 --param
ggc-min-heapsize=130814
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/i686-pc-cygwin/include"
ignoring duplicate directory
"/usr/i686-pc-cygwin/lib/../../include/w32api"
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/3.3.3
/usr/include/c++/3.3.3/i686-pc-cygwin
/usr/include/c++/3.3.3/backward
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/include
/usr/include
/usr/include/w32api
End of search list.
.. /usr/include/c++/3.3.3/iostream
... /usr/include/c++/3.3.3/i686-pc-cygwin/bits/c++config.h
.... /usr/include/c++/3.3.3/i686-pc-cygwin/bits/os_defines.h
... /usr/include/c++/3.3.3/ostream
.... /usr/include/c++/3.3.3/ios
..... /usr/include/c++/3.3.3/iosfwd
...... /usr/include/c++/3.3.3/i686-pc-cygwin/bits/c++locale.h
....... /usr/include/c++/3.3.3/clocale
........ /usr/include/locale.h
......... /usr/include/_ansi.h
.......... /usr/include/newlib.h
.......... /usr/include/sys/config.h
........... /usr/include/machine/ieeefp.h
........... /usr/include/cygwin/config.h
...... /usr/include/c++/3.3.3/cctype
....... /usr/include/ctype.h
...... /usr/include/c++/3.3.3/bits/stringfwd.h
...... /usr/include/c++/3.3.3/bits/fpos.h
....... /usr/include/c++/3.3.3/i686-pc-cygwin/bits/c++io.h
........ /usr/include/c++/3.3.3/cstdio
......... /usr/include/c++/3.3.3/cstddef
.......... /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/include/stddef.h
......... /usr/include/stdio.h
.......... /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/include/stddef.h
.......... /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/include/stdarg.h
.......... /usr/include/sys/reent.h
........... /usr/include/sys/_types.h
............ /usr/include/sys/lock.h
............ /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/include/stddef.h
.......... /usr/include/sys/types.h
........... /usr/include/machine/_types.h
........... /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/include/stddef.h
........... /usr/include/machine/types.h
........... /usr/include/sys/features.h
........... /usr/include/cygwin/types.h
............ /usr/include/sys/sysmacros.h
............ /usr/include/stdint.h
.......... /usr/include/sys/stdio.h
........ /usr/include/c++/3.3.3/i686-pc-cygwin/bits/gthr.h
......... /usr/include/c++/3.3.3/i686-pc-cygwin/bits/gthr-default.h
.......... /usr/include/pthread.h
........... /usr/include/signal.h
............ /usr/include/sys/signal.h
............. /usr/include/cygwin/signal.h
........... /usr/include/sched.h
............ /usr/include/time.h
............. /usr/include/machine/time.h
............. /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/include/stddef.h
.......... /usr/include/unistd.h
........... /usr/include/sys/unistd.h
............ /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/include/stddef.h
............ /usr/include/getopt.h
....... /usr/include/c++/3.3.3/cwchar
........ /usr/include/c++/3.3.3/ctime
........ /usr/include/wchar.h
......... /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/include/stddef.h
...... /usr/include/c++/3.3.3/bits/functexcept.h
....... /usr/include/c++/3.3.3/exception_defines.h
..... /usr/include/c++/3.3.3/exception
..... /usr/include/c++/3.3.3/bits/char_traits.h
...... /usr/include/c++/3.3.3/cstring
....... /usr/include/string.h
........ /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/include/stddef.h
........ /usr/include/sys/string.h
..... /usr/include/c++/3.3.3/bits/localefwd.h
...... /usr/include/c++/3.3.3/bits/functexcept.h
....... /usr/include/c++/3.3.3/exception_defines.h
..... /usr/include/c++/3.3.3/bits/ios_base.h
...... /usr/include/c++/3.3.3/i686-pc-cygwin/bits/atomicity.h
...... /usr/include/c++/3.3.3/bits/locale_classes.h
....... /usr/include/c++/3.3.3/string
........ /usr/include/c++/3.3.3/memory
......... /usr/include/c++/3.3.3/bits/stl_algobase.h
.......... /usr/include/c++/3.3.3/climits
........... /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/include/limits.h
............ /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/include/syslimits.h
............. /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/include/limits.h
.............. /usr/include/limits.h
.......... /usr/include/c++/3.3.3/cstdlib
........... /usr/include/stdlib.h
............ /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/include/stddef.h
............ /usr/include/machine/stdlib.h
............ /usr/include/alloca.h
.......... /usr/include/c++/3.3.3/new
.......... /usr/include/c++/3.3.3/bits/stl_pair.h
.......... /usr/include/c++/3.3.3/bits/type_traits.h
.......... /usr/include/c++/3.3.3/bits/stl_iterator_base_types.h
.......... /usr/include/c++/3.3.3/bits/stl_iterator_base_funcs.h
........... /usr/include/c++/3.3.3/bits/concept_check.h
.......... /usr/include/c++/3.3.3/bits/stl_iterator.h
......... /usr/include/c++/3.3.3/bits/stl_alloc.h
.......... /usr/include/c++/3.3.3/bits/functexcept.h
........... /usr/include/c++/3.3.3/exception_defines.h
.......... /usr/include/c++/3.3.3/bits/stl_threads.h
......... /usr/include/c++/3.3.3/bits/stl_construct.h
......... /usr/include/c++/3.3.3/bits/stl_uninitialized.h
......... /usr/include/c++/3.3.3/bits/stl_raw_storage_iter.h
........ /usr/include/c++/3.3.3/bits/stl_function.h
........ /usr/include/c++/3.3.3/bits/basic_string.h
........ /usr/include/c++/3.3.3/algorithm
......... /usr/include/c++/3.3.3/bits/stl_algo.h
.......... /usr/include/c++/3.3.3/bits/stl_heap.h
.......... /usr/include/c++/3.3.3/bits/stl_tempbuf.h
........ /usr/include/c++/3.3.3/bits/basic_string.tcc
..... /usr/include/c++/3.3.3/streambuf
...... /usr/include/c++/3.3.3/bits/streambuf.tcc
..... /usr/include/c++/3.3.3/bits/basic_ios.h
...... /usr/include/c++/3.3.3/bits/streambuf_iterator.h
...... /usr/include/c++/3.3.3/bits/locale_facets.h
....... /usr/include/c++/3.3.3/cwctype
........ /usr/include/wctype.h
......... /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/include/stddef.h
....... /usr/include/c++/3.3.3/i686-pc-cygwin/bits/ctype_base.h
....... /usr/include/c++/3.3.3/i686-pc-cygwin/bits/ctype_inline.h
....... /usr/include/c++/3.3.3/bits/codecvt.h
....... /usr/include/c++/3.3.3/i686-pc-cygwin/bits/time_members.h
....... /usr/include/c++/3.3.3/i686-pc-cygwin/bits/messages_members.h
...... /usr/include/c++/3.3.3/bits/basic_ios.tcc
.... /usr/include/c++/3.3.3/bits/ostream.tcc
..... /usr/include/c++/3.3.3/locale
...... /usr/include/c++/3.3.3/bits/locale_facets.tcc
....... /usr/include/c++/3.3.3/cerrno
........ /usr/include/errno.h
......... /usr/include/sys/errno.h
....... /usr/include/c++/3.3.3/cmath
........ /usr/include/math.h
......... /usr/include/machine/ieeefp.h
........ /usr/include/c++/3.3.3/bits/cmath.tcc
....... /usr/include/c++/3.3.3/limits
....... /usr/include/c++/3.3.3/typeinfo
... /usr/include/c++/3.3.3/istream
.... /usr/include/c++/3.3.3/bits/istream.tcc
hellow.cpp: In function `int main(int, char**)':
hellow.cpp:4: error: `cout' undeclared (first use this function)
hellow.cpp:4: error: (Each undeclared identifier is reported only once
for each

function it appears in.)
hellow.cpp:4: error: `endl' undeclared (first use this function)
Multiple include guards may be useful for:
/usr/include/c++/3.3.3/bits/istream.tcc
/usr/include/c++/3.3.3/bits/ostream.tcc
/usr/include/c++/3.3.3/i686-pc-cygwin/bits/ctype_base.h
/usr/include/c++/3.3.3/i686-pc-cygwin/bits/ctype_inline.h
/usr/include/c++/3.3.3/i686-pc-cygwin/bits/messages_members.h
/usr/include/c++/3.3.3/i686-pc-cygwin/bits/time_members.h
/usr/include/cygwin/types.h
/usr/include/getopt.h
/usr/include/pthread.h
/usr/include/sys/string.h
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/include/syslimits.h

#
perl -e \
'printf "mailto%c%s%c%s%cjpmchase%ccom%c", 58, "Gerard", 46, "Oberle",
64,
46, 10;' -e 'printf "mailto%c%c%s%cearthlink%cnet%c", 58, 103,
"oberle", 64, 46, 10;'

Jul 23 '05 #1
4 13342
go*****@hotmail.com wrote:
I have installed the Cygwin package under WinXP. I am trying to insure
that I have a reasonable development environment, and that things are
working properly, by trying to compile and run the following classic
program.

$ cat hellow.cpp
#include <iostream>

int main (int argc, char *argv[]) {
//cout << "Hello, world" << endl;

std::cout << "Hello, world" << std::endl;
}
However, when I try to compile, I get

$ g++ hellow.cpp
hellow.cpp: In function `int main(int, char**)':
hellow.cpp:4: error: `cout' undeclared (first use this function)
hellow.cpp:4: error: (Each undeclared identifier is reported only
once for each function it appears in.)
hellow.cpp:4: error: `endl' undeclared (first use this function)

In trying to get more comprehensive infomation, I tried the command
shown below with its output.

If I'm doing something pathetically stupid, do not hesitate to tell me
so --- I've been doing Java for a few years, and I may have forgotten
something really important. :-) Thanks in advance for any help.

- Jerry Oberle


[snip]

Things from the standard headers are in the 'std' namespace.
If you're not familiar with this, read up on it.

See my corrected line in your code above.

Larry
Jul 23 '05 #2
Or you could do

using namespace std;

int main (...) {
cout << "Hello, world" << endl;
}

But, as Larry said, freshen up on namespaces.
Are there such in Java?

-- Pelle

Larry I Smith skrev:
go*****@hotmail.com wrote:
I have installed the Cygwin package under WinXP. I am trying to insure
that I have a reasonable development environment, and that things are
working properly, by trying to compile and run the following classic
program.

$ cat hellow.cpp
#include <iostream>

int main (int argc, char *argv[]) {
//cout << "Hello, world" << endl;


std::cout << "Hello, world" << std::endl;

}
However, when I try to compile, I get

$ g++ hellow.cpp
hellow.cpp: In function `int main(int, char**)':
hellow.cpp:4: error: `cout' undeclared (first use this function)
hellow.cpp:4: error: (Each undeclared identifier is reported only
once for each function it appears in.)
hellow.cpp:4: error: `endl' undeclared (first use this function)

In trying to get more comprehensive infomation, I tried the command
shown below with its output.

If I'm doing something pathetically stupid, do not hesitate to tell me
so --- I've been doing Java for a few years, and I may have forgotten
something really important. :-) Thanks in advance for any help.

- Jerry Oberle

[snip]

Things from the standard headers are in the 'std' namespace.
If you're not familiar with this, read up on it.

See my corrected line in your code above.

Larry

Jul 23 '05 #3
Pelle Beckman wrote:
Or you could do

using namespace std;

int main (...) {
cout << "Hello, world" << endl;
}

But, as Larry said, freshen up on namespaces.
Are there such in Java?

-- Pelle


Be careful. Blanket use of "using namespace std;"
in large systems can get you into trouble.
Remember that one of the reasons for namespaces is to
prevent hard-to-track-down bugs due to name clashes.
It's ok is a trivial example like this program, but
should not be used indiscriminately.

Regards,
Larry
Jul 23 '05 #4
And this means putting the using directive in the main function is a better
option:

#include <iostream>

int main(int argc, char* argv[])
{
using namespace std;
cout << "Hello again!" << end;
}

Or, even better, use a "using-declarative":

#include <iostream>

int main(int argc, char* argv[])
{
using std::cout;
using std::endl;

cout << "Well, I know, hello again..." << endl;
}

regards,
ben
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: dw | last post by:
Pehaba, does anyone knows how to install MySQLdb on cygwin? - test device: MySQLdb 0.9.2.0 targz + cygwin 1.5.7-cr-0x9e + python 2.3.3 on cygwin + mysql 4.0.17 win32 - modified setup.py's...
9
by: Mayer | last post by:
Hello: I'm running python under cygwin and need to find the drive letter. Cygwin has a way of calling my drives by a name relative to the Cygwin directory, so I get things like /home/user rather...
4
by: Vish | last post by:
I cannot compile a simple code as below using cygwin. I believe I am using latest version of g++(3.3.1) I get following error is_equal.cpp:9:19: ccc.cpp: No such file or directory...
12
by: Eugene A | last post by:
Hello. I am trying to compile a linux socket server and a client in cygwin on windows. The g++ version is 3.3.1. The source was obtained from this location: ...
22
by: TuPLaD | last post by:
Hello, I just made a little C++ console application: #include "iostream" using namespace std; int main () { cout << "Hello Mars !"; return 0;
2
by: 63q2o4i02 | last post by:
Hi, I'm using python 2.4 and windows XP. I have two packages in the windows version of python in site-packages. They are PyVisa and ctypes, and both live in c:\python24\lib\site-packages ...
4
by: reachsamdurai | last post by:
Hello, Can you please let me know the procedure to reach db2 command prompt from a cygwin window (hence without using Start-> Run -> db2cmd method). I'm planning to write shell scripts which...
1
by: edwardzyang | last post by:
I am running Windows XP with cygwin with gcc 3.4.4-1 and gdb 20060706-2. I compiled this very simple program: #include <iostream> using namespace std; int main(int argc, char (*(argv)) ) {...
0
by: dot | last post by:
I spent a few headache filled days trying to use GMP on windows (XP pro) I finally got it to work and since I found little help on the Web I thought someone might find what i did useful. ...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.