LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   gcc with iostream problem (https://www.linuxquestions.org/questions/programming-9/gcc-with-iostream-problem-53907/)

rob99 04-07-2003 05:56 PM

gcc with iostream problem
 
Hi All,
Just started on linux and like to write some c++ programs,
but in the very beginning I was stopped on something simple
I think:
#include <iostream.h>
int main()
{
cout<<"test";
}
when I use gcc test.cpp ,
I'm getting error: "undefine reference to std::cout"
On windows I don't have problems with that.

thanks

macewan 04-07-2003 06:42 PM

(disclaimer: I AM NOT A PROGRAMMER!)

vi bob.C
[type in the bob program]
:wq
g++ -Wno-deprecated bob.C -o bob
./bob

Tinkster 04-07-2003 06:59 PM

That's a linker error mate ...

Could you please copy & paste
exactly what you did to get there,
a description of you distro and the
gcc version would be nice to know,
too .. :)

Cheers,
Tink

rob99 04-07-2003 07:57 PM

macewan,
thanks, it works now, but why gcc doesn't want?
I can use g++, but I thought that gcc is c++ compiler.
thanks!

Tinkster 04-07-2003 08:19 PM

Read man gcc :) and find out that you thought
wrong...

Cheers,
Tink

macewan 04-07-2003 08:58 PM

Quote:

Originally posted by rob99
macewan,
thanks, it works now, but why gcc doesn't want?
I can use g++, but I thought that gcc is c++ compiler.
thanks!

don't know the answer. I am not a programmer. Currently teaching myself c++ and that works for me : ) so I used it instead of gcc

kenulla 04-10-2003 02:12 PM

Quote:

Originally posted by rob99
macewan,
thanks, it works now, but why gcc doesn't want?
I can use g++, but I thought that gcc is c++ compiler.
thanks!

gcc can compile many languages, it used to stand for gnu c compiler but now it has been changed to gnu compiler collection, you were experiencing a linking problem.
g++ is a program that invokes gcc with the default language set to C++ and automatically links to c++ libraries

Pwcca 04-16-2003 06:56 PM

cant you specify a language for gcc to compile with the -x option?

macewan 04-16-2003 07:16 PM

#include <iostream.h>
int main()
{
cout << "test";
return 0;
}




///////////////////////
i have to return 0 in the case above.

Tinkster 04-16-2003 09:56 PM

Quote:

Originally posted by Pwcca
cant you specify a language for gcc to compile with the -x option?
Yes you can...

-x language
Specify explicitly the language for the following
input files (rather than choosing a default based
on the file name suffix) . This option applies to
all following input files until the next `-x' op-
tion. Possible values of language are `c', `objec-
tive-c', `c-header', `c++', `cpp-output', `assem-
bler', and `assembler-with-cpp'.

Cheers,
Tink


All times are GMT -5. The time now is 04:34 PM.