public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* help, gcc, ?cout error?
@ 1999-12-11 17:34 aka007
  1999-12-11 17:49 ` Dave Topham
                   ` (3 more replies)
  0 siblings, 4 replies; 20+ messages in thread
From: aka007 @ 1999-12-11 17:34 UTC (permalink / raw)
  To: help-gcc

just trying to get a simple "hello" program to compile,
it is not recognizing "cout", i _think_.

if i modify the program, put the comment // before
the cout line, then it apparently compiles...

alternatively,  how about a program to have to integers,
a,b.  a=2, b=3, a+b=?

no output, just to see if this is my problem, or gcc.

here's what i type into my telnet session:

dana% gcc a.cpp
Undefined                       first referenced
 symbol                             in file
cout                                /var/tmp/ccFWrI6_1.o
__ls__7ostreamPCc                   /var/tmp/ccFWrI6_1.o
ld: fatal: Symbol referencing errors. No output written to a.out

my file is called "a.cpp", of course. dana% is just the place where i
type "pine" to read email, or "ls" to see files, or "mv" to rename a
file, or "pico" to make a text file.

now, here the source for my program.  can someone help me with the
problem.



   UW PICO(tm) 2.9                  File: a.cpp

#include <iostream.h>	//which one do i need?
#include <iomanip.h>
#include <stdio.h>


void main()
  {

        cout << "hello";

  }

thanks,

Jesse
aka007@mail.com

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: help, gcc, ?cout error?
  1999-12-11 17:34 help, gcc, ?cout error? aka007
@ 1999-12-11 17:49 ` Dave Topham
  1999-12-11 20:34   ` aka007
  1999-12-31 22:24   ` Dave Topham
  1999-12-11 17:49 ` Dave Topham
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 20+ messages in thread
From: Dave Topham @ 1999-12-11 17:49 UTC (permalink / raw)
  To: help-gcc

All you need for cout is <iostream>
There may be a conflict using that in addition to <stdio.h>
(I'm not an expert, but this is my thoughts on it!)
-Dave

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: help, gcc, ?cout error?
  1999-12-11 17:34 help, gcc, ?cout error? aka007
  1999-12-11 17:49 ` Dave Topham
@ 1999-12-11 17:49 ` Dave Topham
  1999-12-31 22:24   ` Dave Topham
  1999-12-12 21:35 ` aka007
  1999-12-31 22:24 ` aka007
  3 siblings, 1 reply; 20+ messages in thread
From: Dave Topham @ 1999-12-11 17:49 UTC (permalink / raw)
  To: help-gcc

All you need for cout is <iostream>
There may be a conflict using that in addition to <stdio.h>
(I'm not an expert, but this is my thoughts on it!)
-Dave

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: help, gcc, ?cout error?
  1999-12-11 17:49 ` Dave Topham
@ 1999-12-11 20:34   ` aka007
  1999-12-12  9:09     ` Tom Barron
  1999-12-31 22:24     ` aka007
  1999-12-31 22:24   ` Dave Topham
  1 sibling, 2 replies; 20+ messages in thread
From: aka007 @ 1999-12-11 20:34 UTC (permalink / raw)
  To: help-gcc

i modified it a bit, here is the current version:

   UW PICO(tm) 2.9                  File: a.cpp

#include <iostream.h>

int main()
  {

        int a;
        int b;
        int c;

        a=5;
        b=2;

        c= a+b;

        cout << a;

        return 0;
  }


if i comment out, //, the cout, it compiles

get the same error....

Jesse
aka007@mail.com


On Sat, 11 Dec 1999 17:36:28 -0800, Dave Topham
<dtopham@csuhayward.edu> wrote:

>All you need for cout is <iostream>
>There may be a conflict using that in addition to <stdio.h>
>(I'm not an expert, but this is my thoughts on it!)
>-Dave
>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: help, gcc, ?cout error?
  1999-12-11 20:34   ` aka007
@ 1999-12-12  9:09     ` Tom Barron
  1999-12-12 12:35       ` aka007
  1999-12-31 22:24       ` Tom Barron
  1999-12-31 22:24     ` aka007
  1 sibling, 2 replies; 20+ messages in thread
From: Tom Barron @ 1999-12-12  9:09 UTC (permalink / raw)
  To: help-gcc

Hi, Jesse.  I pasted your code into a file called jesse.cpp on my
system.  Watch this:

$ gcc jesse.cpp
/tmp/ccyMXXQa.o: In function `main':
/tmp/ccyMXXQa.o(.text+0x25): undefined reference to `cout'
/tmp/ccyMXXQa.o(.text+0x2a): undefined reference to
`ostream::operator<<(int)'
collect2: ld returned 1 exit status
$ g++ jesse.cpp
$ a.out
5$ 

The problem is that cout and iostream.h are part of C++, but gcc only
handles C.  To compile C++ code, you need to invoke the compiler as g++.

To get a newline on the end of your output, you might want to do

     cout << a << endl;

hth...
Tom

aka007@mail.com wrote:
> 
> i modified it a bit, here is the current version:
> 
>    UW PICO(tm) 2.9                  File: a.cpp
> ...

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: help, gcc, ?cout error?
  1999-12-12  9:09     ` Tom Barron
@ 1999-12-12 12:35       ` aka007
  1999-12-12 15:35         ` Rick Dearman
                           ` (3 more replies)
  1999-12-31 22:24       ` Tom Barron
  1 sibling, 4 replies; 20+ messages in thread
From: aka007 @ 1999-12-12 12:35 UTC (permalink / raw)
  To: help-gcc

thanks for letting me know what the diff was with gcc vs g++...

hope this is still valid here?  anyhow, here is current version of my
"hello" program:

UW PICO(tm) 2.9                  File: a.cpp

#include <iostream>
using namespace std;

int main() {
  cout << "hello";
  return 0;
}

using command g++ -o a a.cpp , then it "thinks" for a moment, but
creates no output on the telnet session screen.  pico a.out reveals an
empty file, no "hello" in there at all...    at least no error
messages.

so, i'm not even really positive my school has g++, but it doesn't
create an error when i try it using g++, so i figure it is on the
system?  how can i know for sure?  i thought a simple "hello" program,
to confirm i'll be able to do some programming, but maybe not.

any thoughts?

Jesse
aka007@mail.com


On Sun, 12 Dec 1999 10:31:31 -0600, Tom Barron
<tbarron@mindspring.com> wrote:

>Hi, Jesse.  I pasted your code into a file called jesse.cpp on my
>system.  Watch this:
>
>$ gcc jesse.cpp
>/tmp/ccyMXXQa.o: In function `main':
>/tmp/ccyMXXQa.o(.text+0x25): undefined reference to `cout'
>/tmp/ccyMXXQa.o(.text+0x2a): undefined reference to
>`ostream::operator<<(int)'
>collect2: ld returned 1 exit status
>$ g++ jesse.cpp
>$ a.out
>5$ 
>
>The problem is that cout and iostream.h are part of C++, but gcc only
>handles C.  To compile C++ code, you need to invoke the compiler as g++.
>
>To get a newline on the end of your output, you might want to do
>
>     cout << a << endl;
>
>hth...
>Tom
>
>aka007@mail.com wrote:
>> 
>> i modified it a bit, here is the current version:
>> 
>>    UW PICO(tm) 2.9                  File: a.cpp
>> ...

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: help, gcc, ?cout error?
  1999-12-12 12:35       ` aka007
@ 1999-12-12 15:35         ` Rick Dearman
  1999-12-31 22:24           ` Rick Dearman
  1999-12-12 19:56         ` Arthur Gold
                           ` (2 subsequent siblings)
  3 siblings, 1 reply; 20+ messages in thread
From: Rick Dearman @ 1999-12-12 15:35 UTC (permalink / raw)
  To: help-gcc

Use C !

#include <stdio.h>

int
main (void)
{
printf("Hello\n");
return 0;
}

gcc -o hello hello.c

./hello



aka007@mail.com wrote:
> 
> thanks for letting me know what the diff was with gcc vs g++...
> 
> hope this is still valid here?  anyhow, here is current version of my
> "hello" program:
> 
> UW PICO(tm) 2.9                  File: a.cpp
> 
> #include <iostream>
> using namespace std;
> 
> int main() {
>   cout << "hello";
>   return 0;
> }
> 
> using command g++ -o a a.cpp , then it "thinks" for a moment, but
> creates no output on the telnet session screen.  pico a.out reveals an
> empty file, no "hello" in there at all...    at least no error
> messages.
> 
> so, i'm not even really positive my school has g++, but it doesn't
> create an error when i try it using g++, so i figure it is on the
> system?  how can i know for sure?  i thought a simple "hello" program,
> to confirm i'll be able to do some programming, but maybe not.
> 
> any thoughts?
> 
> Jesse
> aka007@mail.com
> 
> On Sun, 12 Dec 1999 10:31:31 -0600, Tom Barron
> <tbarron@mindspring.com> wrote:
> 
> >Hi, Jesse.  I pasted your code into a file called jesse.cpp on my
> >system.  Watch this:
> >
> >$ gcc jesse.cpp
> >/tmp/ccyMXXQa.o: In function `main':
> >/tmp/ccyMXXQa.o(.text+0x25): undefined reference to `cout'
> >/tmp/ccyMXXQa.o(.text+0x2a): undefined reference to
> >`ostream::operator<<(int)'
> >collect2: ld returned 1 exit status
> >$ g++ jesse.cpp
> >$ a.out
> >5$
> >
> >The problem is that cout and iostream.h are part of C++, but gcc only
> >handles C.  To compile C++ code, you need to invoke the compiler as g++.
> >
> >To get a newline on the end of your output, you might want to do
> >
> >     cout << a << endl;
> >
> >hth...
> >Tom
> >
> >aka007@mail.com wrote:
> >>
> >> i modified it a bit, here is the current version:
> >>
> >>    UW PICO(tm) 2.9                  File: a.cpp
> >> ...

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: help, gcc, ?cout error?
  1999-12-12 12:35       ` aka007
  1999-12-12 15:35         ` Rick Dearman
@ 1999-12-12 19:56         ` Arthur Gold
  1999-12-31 22:24           ` Arthur Gold
  1999-12-13 10:01         ` Greg Wimpey
  1999-12-31 22:24         ` aka007
  3 siblings, 1 reply; 20+ messages in thread
From: Arthur Gold @ 1999-12-12 19:56 UTC (permalink / raw)
  To: help-gcc

aka007@mail.com wrote:
> 
> thanks for letting me know what the diff was with gcc vs g++...
> 
> hope this is still valid here?  anyhow, here is current version of my
> "hello" program:
> 
> UW PICO(tm) 2.9                  File: a.cpp
> 
> #include <iostream>
> using namespace std;
> 
> int main() {
>   cout << "hello";
As stdout is bufferred (stdout being where 'cout' sends output) unless
you terminate your output with a newline (either by saying cout <<
"hello\n" or cout << "hello" << endl) you won't see any output.

HTH,
--ag

>   return 0;
> }
> 
> using command g++ -o a a.cpp , then it "thinks" for a moment, but
> creates no output on the telnet session screen.  pico a.out reveals an
> empty file, no "hello" in there at all...    at least no error
> messages.
> 
> so, i'm not even really positive my school has g++, but it doesn't
> create an error when i try it using g++, so i figure it is on the
> system?  how can i know for sure?  i thought a simple "hello" program,
> to confirm i'll be able to do some programming, but maybe not.
> 
> any thoughts?
> 
> Jesse
> aka007@mail.com
> 
> On Sun, 12 Dec 1999 10:31:31 -0600, Tom Barron
> <tbarron@mindspring.com> wrote:
> 
> >Hi, Jesse.  I pasted your code into a file called jesse.cpp on my
> >system.  Watch this:
> >
> >$ gcc jesse.cpp
> >/tmp/ccyMXXQa.o: In function `main':
> >/tmp/ccyMXXQa.o(.text+0x25): undefined reference to `cout'
> >/tmp/ccyMXXQa.o(.text+0x2a): undefined reference to
> >`ostream::operator<<(int)'
> >collect2: ld returned 1 exit status
> >$ g++ jesse.cpp
> >$ a.out
> >5$
> >
> >The problem is that cout and iostream.h are part of C++, but gcc only
> >handles C.  To compile C++ code, you need to invoke the compiler as g++.
> >
> >To get a newline on the end of your output, you might want to do
> >
> >     cout << a << endl;
> >
> >hth...
> >Tom
> >
> >aka007@mail.com wrote:
> >>
> >> i modified it a bit, here is the current version:
> >>
> >>    UW PICO(tm) 2.9                  File: a.cpp
> >> ...

-- 
Artie Gold, Austin, TX  (finger the cs.utexas.edu account for more info)
mailto:agold@bga.com or mailto:agold@cs.utexas.edu
--
A: Look for a lawyer who speaks Aramaic...about trademark infringement.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: help, gcc, ?cout error?
  1999-12-11 17:34 help, gcc, ?cout error? aka007
  1999-12-11 17:49 ` Dave Topham
  1999-12-11 17:49 ` Dave Topham
@ 1999-12-12 21:35 ` aka007
  1999-12-31 22:24   ` aka007
  1999-12-31 22:24 ` aka007
  3 siblings, 1 reply; 20+ messages in thread
From: aka007 @ 1999-12-12 21:35 UTC (permalink / raw)
  To: help-gcc

ok, thanks all :)

i eventually used c, and compiled with one command, then ran with
another command.

thanks,

Jesse
aka007@mail.com

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: help, gcc, ?cout error?
  1999-12-12 12:35       ` aka007
  1999-12-12 15:35         ` Rick Dearman
  1999-12-12 19:56         ` Arthur Gold
@ 1999-12-13 10:01         ` Greg Wimpey
  1999-12-31 22:24           ` Greg Wimpey
  1999-12-31 22:24         ` aka007
  3 siblings, 1 reply; 20+ messages in thread
From: Greg Wimpey @ 1999-12-13 10:01 UTC (permalink / raw)
  To: help-gcc

aka007@mail.com writes:

> thanks for letting me know what the diff was with gcc vs g++...
> 
> hope this is still valid here?  anyhow, here is current version of my
> "hello" program:
> 
> UW PICO(tm) 2.9                  File: a.cpp
> 
> #include <iostream>
> using namespace std;
> 
> int main() {
>   cout << "hello";
>   return 0;
> }
> 
> using command g++ -o a a.cpp , then it "thinks" for a moment, but
> creates no output on the telnet session screen.  pico a.out reveals an
> empty file, no "hello" in there at all...    at least no error
> messages.
> 

Does your code really say "#include <iostream>"?  That should be
"#include <iostream.h>", unless GCC has some facility for automagically
tacking the ".h" onto the end of the file name.

Second, the command line "g++ -o a a.cpp" will put the compiled code
in a file called "a", not "a.out".  You'll only see output in "a.out" if
you don't give it an output file name with the "-o" flag.

Finally, you shouldn't expect to see "hello" in your compiler output.
Your compiler output will be the executable, not the output of the program.
You need to execute the code; then you'll see the output.  It should go
something like this:

% g++ -o a a.cpp
% ./a
hello %

(Note that the lack of a newline ("\n") in your string means that the 
prompt will appear on the same line as your output.)

-- 
Greg Wimpey
greg.wimpey@waii*removetomail*.com.invalid

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: help, gcc, ?cout error?
  1999-12-12  9:09     ` Tom Barron
  1999-12-12 12:35       ` aka007
@ 1999-12-31 22:24       ` Tom Barron
  1 sibling, 0 replies; 20+ messages in thread
From: Tom Barron @ 1999-12-31 22:24 UTC (permalink / raw)
  To: help-gcc

Hi, Jesse.  I pasted your code into a file called jesse.cpp on my
system.  Watch this:

$ gcc jesse.cpp
/tmp/ccyMXXQa.o: In function `main':
/tmp/ccyMXXQa.o(.text+0x25): undefined reference to `cout'
/tmp/ccyMXXQa.o(.text+0x2a): undefined reference to
`ostream::operator<<(int)'
collect2: ld returned 1 exit status
$ g++ jesse.cpp
$ a.out
5$ 

The problem is that cout and iostream.h are part of C++, but gcc only
handles C.  To compile C++ code, you need to invoke the compiler as g++.

To get a newline on the end of your output, you might want to do

     cout << a << endl;

hth...
Tom

aka007@mail.com wrote:
> 
> i modified it a bit, here is the current version:
> 
>    UW PICO(tm) 2.9                  File: a.cpp
> ...

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: help, gcc, ?cout error?
  1999-12-11 20:34   ` aka007
  1999-12-12  9:09     ` Tom Barron
@ 1999-12-31 22:24     ` aka007
  1 sibling, 0 replies; 20+ messages in thread
From: aka007 @ 1999-12-31 22:24 UTC (permalink / raw)
  To: help-gcc

i modified it a bit, here is the current version:

   UW PICO(tm) 2.9                  File: a.cpp

#include <iostream.h>

int main()
  {

        int a;
        int b;
        int c;

        a=5;
        b=2;

        c= a+b;

        cout << a;

        return 0;
  }


if i comment out, //, the cout, it compiles

get the same error....

Jesse
aka007@mail.com


On Sat, 11 Dec 1999 17:36:28 -0800, Dave Topham
<dtopham@csuhayward.edu> wrote:

>All you need for cout is <iostream>
>There may be a conflict using that in addition to <stdio.h>
>(I'm not an expert, but this is my thoughts on it!)
>-Dave
>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: help, gcc, ?cout error?
  1999-12-12 21:35 ` aka007
@ 1999-12-31 22:24   ` aka007
  0 siblings, 0 replies; 20+ messages in thread
From: aka007 @ 1999-12-31 22:24 UTC (permalink / raw)
  To: help-gcc

ok, thanks all :)

i eventually used c, and compiled with one command, then ran with
another command.

thanks,

Jesse
aka007@mail.com

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: help, gcc, ?cout error?
  1999-12-11 17:49 ` Dave Topham
@ 1999-12-31 22:24   ` Dave Topham
  0 siblings, 0 replies; 20+ messages in thread
From: Dave Topham @ 1999-12-31 22:24 UTC (permalink / raw)
  To: help-gcc

All you need for cout is <iostream>
There may be a conflict using that in addition to <stdio.h>
(I'm not an expert, but this is my thoughts on it!)
-Dave

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: help, gcc, ?cout error?
  1999-12-12 12:35       ` aka007
                           ` (2 preceding siblings ...)
  1999-12-13 10:01         ` Greg Wimpey
@ 1999-12-31 22:24         ` aka007
  3 siblings, 0 replies; 20+ messages in thread
From: aka007 @ 1999-12-31 22:24 UTC (permalink / raw)
  To: help-gcc

thanks for letting me know what the diff was with gcc vs g++...

hope this is still valid here?  anyhow, here is current version of my
"hello" program:

UW PICO(tm) 2.9                  File: a.cpp

#include <iostream>
using namespace std;

int main() {
  cout << "hello";
  return 0;
}

using command g++ -o a a.cpp , then it "thinks" for a moment, but
creates no output on the telnet session screen.  pico a.out reveals an
empty file, no "hello" in there at all...    at least no error
messages.

so, i'm not even really positive my school has g++, but it doesn't
create an error when i try it using g++, so i figure it is on the
system?  how can i know for sure?  i thought a simple "hello" program,
to confirm i'll be able to do some programming, but maybe not.

any thoughts?

Jesse
aka007@mail.com


On Sun, 12 Dec 1999 10:31:31 -0600, Tom Barron
<tbarron@mindspring.com> wrote:

>Hi, Jesse.  I pasted your code into a file called jesse.cpp on my
>system.  Watch this:
>
>$ gcc jesse.cpp
>/tmp/ccyMXXQa.o: In function `main':
>/tmp/ccyMXXQa.o(.text+0x25): undefined reference to `cout'
>/tmp/ccyMXXQa.o(.text+0x2a): undefined reference to
>`ostream::operator<<(int)'
>collect2: ld returned 1 exit status
>$ g++ jesse.cpp
>$ a.out
>5$ 
>
>The problem is that cout and iostream.h are part of C++, but gcc only
>handles C.  To compile C++ code, you need to invoke the compiler as g++.
>
>To get a newline on the end of your output, you might want to do
>
>     cout << a << endl;
>
>hth...
>Tom
>
>aka007@mail.com wrote:
>> 
>> i modified it a bit, here is the current version:
>> 
>>    UW PICO(tm) 2.9                  File: a.cpp
>> ...

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: help, gcc, ?cout error?
  1999-12-12 19:56         ` Arthur Gold
@ 1999-12-31 22:24           ` Arthur Gold
  0 siblings, 0 replies; 20+ messages in thread
From: Arthur Gold @ 1999-12-31 22:24 UTC (permalink / raw)
  To: help-gcc

aka007@mail.com wrote:
> 
> thanks for letting me know what the diff was with gcc vs g++...
> 
> hope this is still valid here?  anyhow, here is current version of my
> "hello" program:
> 
> UW PICO(tm) 2.9                  File: a.cpp
> 
> #include <iostream>
> using namespace std;
> 
> int main() {
>   cout << "hello";
As stdout is bufferred (stdout being where 'cout' sends output) unless
you terminate your output with a newline (either by saying cout <<
"hello\n" or cout << "hello" << endl) you won't see any output.

HTH,
--ag

>   return 0;
> }
> 
> using command g++ -o a a.cpp , then it "thinks" for a moment, but
> creates no output on the telnet session screen.  pico a.out reveals an
> empty file, no "hello" in there at all...    at least no error
> messages.
> 
> so, i'm not even really positive my school has g++, but it doesn't
> create an error when i try it using g++, so i figure it is on the
> system?  how can i know for sure?  i thought a simple "hello" program,
> to confirm i'll be able to do some programming, but maybe not.
> 
> any thoughts?
> 
> Jesse
> aka007@mail.com
> 
> On Sun, 12 Dec 1999 10:31:31 -0600, Tom Barron
> <tbarron@mindspring.com> wrote:
> 
> >Hi, Jesse.  I pasted your code into a file called jesse.cpp on my
> >system.  Watch this:
> >
> >$ gcc jesse.cpp
> >/tmp/ccyMXXQa.o: In function `main':
> >/tmp/ccyMXXQa.o(.text+0x25): undefined reference to `cout'
> >/tmp/ccyMXXQa.o(.text+0x2a): undefined reference to
> >`ostream::operator<<(int)'
> >collect2: ld returned 1 exit status
> >$ g++ jesse.cpp
> >$ a.out
> >5$
> >
> >The problem is that cout and iostream.h are part of C++, but gcc only
> >handles C.  To compile C++ code, you need to invoke the compiler as g++.
> >
> >To get a newline on the end of your output, you might want to do
> >
> >     cout << a << endl;
> >
> >hth...
> >Tom
> >
> >aka007@mail.com wrote:
> >>
> >> i modified it a bit, here is the current version:
> >>
> >>    UW PICO(tm) 2.9                  File: a.cpp
> >> ...

-- 
Artie Gold, Austin, TX  (finger the cs.utexas.edu account for more info)
mailto:agold@bga.com or mailto:agold@cs.utexas.edu
--
A: Look for a lawyer who speaks Aramaic...about trademark infringement.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: help, gcc, ?cout error?
  1999-12-13 10:01         ` Greg Wimpey
@ 1999-12-31 22:24           ` Greg Wimpey
  0 siblings, 0 replies; 20+ messages in thread
From: Greg Wimpey @ 1999-12-31 22:24 UTC (permalink / raw)
  To: help-gcc

aka007@mail.com writes:

> thanks for letting me know what the diff was with gcc vs g++...
> 
> hope this is still valid here?  anyhow, here is current version of my
> "hello" program:
> 
> UW PICO(tm) 2.9                  File: a.cpp
> 
> #include <iostream>
> using namespace std;
> 
> int main() {
>   cout << "hello";
>   return 0;
> }
> 
> using command g++ -o a a.cpp , then it "thinks" for a moment, but
> creates no output on the telnet session screen.  pico a.out reveals an
> empty file, no "hello" in there at all...    at least no error
> messages.
> 

Does your code really say "#include <iostream>"?  That should be
"#include <iostream.h>", unless GCC has some facility for automagically
tacking the ".h" onto the end of the file name.

Second, the command line "g++ -o a a.cpp" will put the compiled code
in a file called "a", not "a.out".  You'll only see output in "a.out" if
you don't give it an output file name with the "-o" flag.

Finally, you shouldn't expect to see "hello" in your compiler output.
Your compiler output will be the executable, not the output of the program.
You need to execute the code; then you'll see the output.  It should go
something like this:

% g++ -o a a.cpp
% ./a
hello %

(Note that the lack of a newline ("\n") in your string means that the 
prompt will appear on the same line as your output.)

-- 
Greg Wimpey
greg.wimpey@waii*removetomail*.com.invalid

^ permalink raw reply	[flat|nested] 20+ messages in thread

* help, gcc, ?cout error?
  1999-12-11 17:34 help, gcc, ?cout error? aka007
                   ` (2 preceding siblings ...)
  1999-12-12 21:35 ` aka007
@ 1999-12-31 22:24 ` aka007
  3 siblings, 0 replies; 20+ messages in thread
From: aka007 @ 1999-12-31 22:24 UTC (permalink / raw)
  To: help-gcc

just trying to get a simple "hello" program to compile,
it is not recognizing "cout", i _think_.

if i modify the program, put the comment // before
the cout line, then it apparently compiles...

alternatively,  how about a program to have to integers,
a,b.  a=2, b=3, a+b=?

no output, just to see if this is my problem, or gcc.

here's what i type into my telnet session:

dana% gcc a.cpp
Undefined                       first referenced
 symbol                             in file
cout                                /var/tmp/ccFWrI6_1.o
__ls__7ostreamPCc                   /var/tmp/ccFWrI6_1.o
ld: fatal: Symbol referencing errors. No output written to a.out

my file is called "a.cpp", of course. dana% is just the place where i
type "pine" to read email, or "ls" to see files, or "mv" to rename a
file, or "pico" to make a text file.

now, here the source for my program.  can someone help me with the
problem.



   UW PICO(tm) 2.9                  File: a.cpp

#include <iostream.h>	//which one do i need?
#include <iomanip.h>
#include <stdio.h>


void main()
  {

        cout << "hello";

  }

thanks,

Jesse
aka007@mail.com

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: help, gcc, ?cout error?
  1999-12-12 15:35         ` Rick Dearman
@ 1999-12-31 22:24           ` Rick Dearman
  0 siblings, 0 replies; 20+ messages in thread
From: Rick Dearman @ 1999-12-31 22:24 UTC (permalink / raw)
  To: help-gcc

Use C !

#include <stdio.h>

int
main (void)
{
printf("Hello\n");
return 0;
}

gcc -o hello hello.c

./hello



aka007@mail.com wrote:
> 
> thanks for letting me know what the diff was with gcc vs g++...
> 
> hope this is still valid here?  anyhow, here is current version of my
> "hello" program:
> 
> UW PICO(tm) 2.9                  File: a.cpp
> 
> #include <iostream>
> using namespace std;
> 
> int main() {
>   cout << "hello";
>   return 0;
> }
> 
> using command g++ -o a a.cpp , then it "thinks" for a moment, but
> creates no output on the telnet session screen.  pico a.out reveals an
> empty file, no "hello" in there at all...    at least no error
> messages.
> 
> so, i'm not even really positive my school has g++, but it doesn't
> create an error when i try it using g++, so i figure it is on the
> system?  how can i know for sure?  i thought a simple "hello" program,
> to confirm i'll be able to do some programming, but maybe not.
> 
> any thoughts?
> 
> Jesse
> aka007@mail.com
> 
> On Sun, 12 Dec 1999 10:31:31 -0600, Tom Barron
> <tbarron@mindspring.com> wrote:
> 
> >Hi, Jesse.  I pasted your code into a file called jesse.cpp on my
> >system.  Watch this:
> >
> >$ gcc jesse.cpp
> >/tmp/ccyMXXQa.o: In function `main':
> >/tmp/ccyMXXQa.o(.text+0x25): undefined reference to `cout'
> >/tmp/ccyMXXQa.o(.text+0x2a): undefined reference to
> >`ostream::operator<<(int)'
> >collect2: ld returned 1 exit status
> >$ g++ jesse.cpp
> >$ a.out
> >5$
> >
> >The problem is that cout and iostream.h are part of C++, but gcc only
> >handles C.  To compile C++ code, you need to invoke the compiler as g++.
> >
> >To get a newline on the end of your output, you might want to do
> >
> >     cout << a << endl;
> >
> >hth...
> >Tom
> >
> >aka007@mail.com wrote:
> >>
> >> i modified it a bit, here is the current version:
> >>
> >>    UW PICO(tm) 2.9                  File: a.cpp
> >> ...

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: help, gcc, ?cout error?
  1999-12-11 17:49 ` Dave Topham
  1999-12-11 20:34   ` aka007
@ 1999-12-31 22:24   ` Dave Topham
  1 sibling, 0 replies; 20+ messages in thread
From: Dave Topham @ 1999-12-31 22:24 UTC (permalink / raw)
  To: help-gcc

All you need for cout is <iostream>
There may be a conflict using that in addition to <stdio.h>
(I'm not an expert, but this is my thoughts on it!)
-Dave

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~1999-12-31 22:24 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-11 17:34 help, gcc, ?cout error? aka007
1999-12-11 17:49 ` Dave Topham
1999-12-11 20:34   ` aka007
1999-12-12  9:09     ` Tom Barron
1999-12-12 12:35       ` aka007
1999-12-12 15:35         ` Rick Dearman
1999-12-31 22:24           ` Rick Dearman
1999-12-12 19:56         ` Arthur Gold
1999-12-31 22:24           ` Arthur Gold
1999-12-13 10:01         ` Greg Wimpey
1999-12-31 22:24           ` Greg Wimpey
1999-12-31 22:24         ` aka007
1999-12-31 22:24       ` Tom Barron
1999-12-31 22:24     ` aka007
1999-12-31 22:24   ` Dave Topham
1999-12-11 17:49 ` Dave Topham
1999-12-31 22:24   ` Dave Topham
1999-12-12 21:35 ` aka007
1999-12-31 22:24   ` aka007
1999-12-31 22:24 ` aka007

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).