473,624 Members | 2,564 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_PATCHLE VEL__=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_defin es.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_defin es.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_ba se_types.h
.......... /usr/include/c++/3.3.3/bits/stl_iterator_ba se_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_defin es.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_uninitializ ed.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.tc c
..... /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_itera tor.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_member s.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.t cc
....... /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_member s.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%c earthlink%cnet% c", 58, 103,
"oberle", 64, 46, 10;'

Jul 23 '05 #1
4 13363
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 indiscriminatel y.

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
2326
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 using thread library.. NO, library + include
9
3537
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 than /cygdrive/g/cygwin/home/usr, etc. How can I find the letter of the drive, or in the above example, the letter 'g'? My program needs to run on an external media that comes with Cygwin on it. I have no control over what drive is assigned to...
4
7121
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 is_equal.cpp:11: error: `vector' was not declared in this scope is_equal.cpp:11: error: parse error before `>' token is_equal.cpp: In function `bool equal_vec(...)': is_equal.cpp:12: error: `a' undeclared (first use this function) is_equal.cpp:12: error: (Each...
12
5625
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: http://www.linuxgazette.com/issue74/tougher.html ServerSoccket.cpp apparently compiles OK. Socket.cpp has a problem. Here's
22
2195
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
3223
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 I'd like to move these to the cygwin version of python on the same system. I tried copying the PyVisa and ctypes directorices (including
4
14051
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 accesses DB2 database on windows platform hence I installed cygwin but I'm unable to connect to database as it fails with the error message. $ db2 DB21061E Command line environment not initialized.
1
6745
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)) ) { int max; // number to count to if (argc == 1) { // print to 100
0
3284
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. Creating an environment suitable for GMP programming. 1) Create 'cygwin' environment (see below) 2)add GMP to the cygwin directory (see below)
0
8168
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8614
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7153
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6107
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4167
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2603
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1474
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.