* Program editor programming c++
@ 2008-05-29 10:09 Lopezio
2008-05-29 10:28 ` Axel Freyn
0 siblings, 1 reply; 6+ messages in thread
From: Lopezio @ 2008-05-29 10:09 UTC (permalink / raw)
To: gcc
Hi I use rhide for programming in c++, but i get errors when i compile the
program. It works in rhide environment but doesn't work when i compile it.
Consider the following example
#include "iostream"
int main(){
printf("olare");
return 0;
}
I get error when compile it with gcc ola.cpp -o ola.exe but it works in
rhide environment.
What's the best option editor for programming in cpp and compile with gcc?
Thank you
--
View this message in context: http://www.nabble.com/Program-editor-programming-c%2B%2B-tp17532397p17532397.html
Sent from the gcc - Dev mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Program editor programming c++
2008-05-29 10:09 Program editor programming c++ Lopezio
@ 2008-05-29 10:28 ` Axel Freyn
2008-05-29 21:04 ` Lopezio
0 siblings, 1 reply; 6+ messages in thread
From: Axel Freyn @ 2008-05-29 10:28 UTC (permalink / raw)
To: gcc
Hi,
On Thu, May 29, 2008 at 03:08:34AM -0700, Lopezio wrote:
> #include "iostream"
> int main(){
> printf("olare");
> return 0;
> }
> I get error when compile it with gcc ola.cpp -o ola.exe but it works in
> rhide environment.
Well, your example is neither valid C-code, nor valid C++-code:
- iostream belongs to C++, and not c
- printf is declared in stdio.h, for C
- you should use #include <iostream> instead of "iostream". With "", gcc
searches only in the current directory (and in all directories given given as
include directories on command line)
- the filename should end on ".c" instead of ".cpp". ".cpp" is understood as
C++-code by gcc
- If you see nothing in the output: add a newlin "\n" to the printf-command
- If you compile using "gcc", the compiler does not link to the C++-libraries.
use "g++" instead.
If you use (C-version, ola.c)
#include <stdio.h>
int main(){
printf("olare\n");
return 0;
}
it should work with gcc ola.c -o ola.exe. This also works with
g++ ola.c -o ola.exe
or as
gc ola.cpp -o ola.exe
if you want
As C++ version, I would propose (in ola.cpp):
#include <iostream>
int main(){
std::cout << "olare" << std::endl;
}
with
g++ ola.cpp -o ola.exe
The "best" programming environment depends on what you like - I'm using vim
HTH,
Axel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Program editor programming c++
2008-05-29 10:28 ` Axel Freyn
@ 2008-05-29 21:04 ` Lopezio
2008-05-29 21:18 ` Jan-Benedict Glaw
2008-05-29 21:18 ` Joe Buck
0 siblings, 2 replies; 6+ messages in thread
From: Lopezio @ 2008-05-29 21:04 UTC (permalink / raw)
To: gcc
Hi
Thank you for your help.I'm a beginer on cpp. I'm programming in windows/dos
mode and i get error when i compile the program
#include <iostream>
int main(){
std::cout << "olare" << std::endl;
}
I get error when i compile the program with gcc ola.cpp -o ola.exe
Can you help me?
Thank you
Axel Freyn wrote:
>
> Hi,
> On Thu, May 29, 2008 at 03:08:34AM -0700, Lopezio wrote:
>> #include "iostream"
>> int main(){
>> printf("olare");
>> return 0;
>> }
>> I get error when compile it with gcc ola.cpp -o ola.exe but it works in
>> rhide environment.
> Well, your example is neither valid C-code, nor valid C++-code:
> - iostream belongs to C++, and not c
> - printf is declared in stdio.h, for C
> - you should use #include <iostream> instead of "iostream". With "", gcc
> searches only in the current directory (and in all directories given
> given as
> include directories on command line)
> - the filename should end on ".c" instead of ".cpp". ".cpp" is understood
> as
> C++-code by gcc
> - If you see nothing in the output: add a newlin "\n" to the
> printf-command
> - If you compile using "gcc", the compiler does not link to the
> C++-libraries.
> use "g++" instead.
>
> If you use (C-version, ola.c)
> #include <stdio.h>
> int main(){
> printf("olare\n");
> return 0;
> }
> it should work with gcc ola.c -o ola.exe. This also works with
> g++ ola.c -o ola.exe
> or as
> gc ola.cpp -o ola.exe
> if you want
>
> As C++ version, I would propose (in ola.cpp):
> #include <iostream>
> int main(){
> std::cout << "olare" << std::endl;
> }
> with
> g++ ola.cpp -o ola.exe
>
>
> The "best" programming environment depends on what you like - I'm using
> vim
>
> HTH,
>
> Axel
>
>
>
>
>
--
View this message in context: http://www.nabble.com/Program-editor-programming-c%2B%2B-tp17532397p17545760.html
Sent from the gcc - Dev mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Program editor programming c++
2008-05-29 21:04 ` Lopezio
@ 2008-05-29 21:18 ` Jan-Benedict Glaw
2008-05-29 21:50 ` Lopezio
2008-05-29 21:18 ` Joe Buck
1 sibling, 1 reply; 6+ messages in thread
From: Jan-Benedict Glaw @ 2008-05-29 21:18 UTC (permalink / raw)
To: Lopezio; +Cc: gcc
[-- Attachment #1: Type: text/plain, Size: 1060 bytes --]
On Thu, 2008-05-29 14:04:24 -0700, Lopezio <geral@mariolopes.com> wrote:
> Thank you for your help.I'm a beginer on cpp. I'm programming in windows/dos
> mode and i get error when i compile the program
> #include <iostream>
> int main(){
> std::cout << "olare" << std::endl;
> }
> I get error when i compile the program with gcc ola.cpp -o ola.exe
> Can you help me?
It would have helped if you had the error message included...
But I know what's missing. Remember what was said? The gcc compiler
(being a C compiler that's capable of recognizing and compiling C++
sources) won't include libstdc++ in the linker run. So either add that:
gcc foo.cpp -lstdc++
...or use g++ to compile and link.
MfG, JBG
--
Jan-Benedict Glaw jbglaw@lug-owl.de +49-172-7608481
Signature of: Ich hatte in letzter Zeit ein bißchen viel Realitycheck.
the second : Langsam möchte ich mal wieder weiterträumen können.
-- Maximilian Wilhelm (18. Mai 2006, #lug-owl.de)
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Program editor programming c++
2008-05-29 21:04 ` Lopezio
2008-05-29 21:18 ` Jan-Benedict Glaw
@ 2008-05-29 21:18 ` Joe Buck
1 sibling, 0 replies; 6+ messages in thread
From: Joe Buck @ 2008-05-29 21:18 UTC (permalink / raw)
To: Lopezio; +Cc: gcc
On Thu, May 29, 2008 at 02:04:24PM -0700, Lopezio wrote:
> Hi
> Thank you for your help.I'm a beginer on cpp. I'm programming in windows/dos
> mode and i get error when i compile the program
> #include <iostream>
> int main(){
> std::cout << "olare" << std::endl;
> }
> I get error when i compile the program with gcc ola.cpp -o ola.exe
> Can you help me?
This list is where the developers of gcc communicate; it is not for
user questions. Please use gcc-help. And on that list, please don't
say "I get error". Include the exact error message that you got.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Program editor programming c++
2008-05-29 21:18 ` Jan-Benedict Glaw
@ 2008-05-29 21:50 ` Lopezio
0 siblings, 0 replies; 6+ messages in thread
From: Lopezio @ 2008-05-29 21:50 UTC (permalink / raw)
To: gcc
Thank you guys
g++ solved my problem
Jan-Benedict Glaw wrote:
>
> On Thu, 2008-05-29 14:04:24 -0700, Lopezio <geral@mariolopes.com> wrote:
>> Thank you for your help.I'm a beginer on cpp. I'm programming in
>> windows/dos
>> mode and i get error when i compile the program
>> #include <iostream>
>> int main(){
>> std::cout << "olare" << std::endl;
>> }
>> I get error when i compile the program with gcc ola.cpp -o ola.exe
>> Can you help me?
>
> It would have helped if you had the error message included...
>
> But I know what's missing. Remember what was said? The gcc compiler
> (being a C compiler that's capable of recognizing and compiling C++
> sources) won't include libstdc++ in the linker run. So either add that:
>
> gcc foo.cpp -lstdc++
>
> ...or use g++ to compile and link.
>
> MfG, JBG
>
> --
> Jan-Benedict Glaw jbglaw@lug-owl.de
> +49-172-7608481
> Signature of: Ich hatte in letzter Zeit ein bißchen viel
> Realitycheck.
> the second : Langsam möchte ich mal wieder weiterträumen
> können.
> -- Maximilian Wilhelm (18. Mai 2006,
> #lug-owl.de)
>
>
>
--
View this message in context: http://www.nabble.com/Program-editor-programming-c%2B%2B-tp17532397p17546848.html
Sent from the gcc - Dev mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-05-29 21:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-29 10:09 Program editor programming c++ Lopezio
2008-05-29 10:28 ` Axel Freyn
2008-05-29 21:04 ` Lopezio
2008-05-29 21:18 ` Jan-Benedict Glaw
2008-05-29 21:50 ` Lopezio
2008-05-29 21:18 ` Joe Buck
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).