Home > Archive > alt.os.linux > September 2002 > Simple console C++ programs under linux





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Simple console C++ programs under linux
Anonymous

2002-09-27, 4:29 pm

I'm learning how to use C++, but I've been limited to Windows. How would
I go aout to write programs for linux (mandrake 8.2)? I'm trying to
write simple i/o, nothing with graphics or any of that.

When I compile this (main.cpp) with g++, "Hello World!" appears in a
file called a.out, in the same directory as the source, but I don't see
a binary anywhere.

/* main.cpp */
#include <iostream.h>
int main()
{
cout << "Hello World!";

return 0;
}

I also tried using kdevelop, but it wanted to configure? make? In the
end, I couldn't get it to work.

dmz17

2002-09-27, 4:29 pm

On Fri, 27 Sep 2002 14:32:24 +0000, Anonymous wrote:

> I'm learning how to use C++, but I've been limited to Windows. How would
> I go aout to write programs for linux (mandrake 8.2)? I'm trying to
> write simple i/o, nothing with graphics or any of that.
>
> When I compile this (main.cpp) with g++, "Hello World!" appears in a
> file called a.out, in the same directory as the source, but I don't see
> a binary anywhere.
>
> /* main.cpp */
> #include <iostream.h>
> int main()
> {
> cout << "Hello World!";
>
> return 0;
> }
>
> I also tried using kdevelop, but it wanted to configure? make? In the
> end, I couldn't get it to work.


a.out is the default binary (runnable) output from the compilation and
linking step.

Try this:

g++ main.cpp -o ttt

Then run (./ttt) ttt.

Cheers,

dmz17
Robert Bindler

2002-09-27, 4:29 pm

dmz17 wrote:
> On Fri, 27 Sep 2002 14:32:24 +0000, Anonymous wrote:
>
>
>>I'm learning how to use C++, but I've been limited to Windows. How would
>>I go aout to write programs for linux (mandrake 8.2)? I'm trying to
>>write simple i/o, nothing with graphics or any of that.
>>
>>When I compile this (main.cpp) with g++, "Hello World!" appears in a
>>file called a.out, in the same directory as the source, but I don't see
>>a binary anywhere.
>>
>>/* main.cpp */
>>#include <iostream.h>
>>int main()
>>{
>> cout << "Hello World!";
>>
>> return 0;
>>}
>>
>>I also tried using kdevelop, but it wanted to configure? make? In the
>>end, I couldn't get it to work.

>
>
> a.out is the default binary (runnable) output from the compilation and
> linking step.
>
> Try this:
>
> g++ main.cpp -o ttt
>
> Then run (./ttt) ttt.
>
> Cheers,
>
> dmz17


Thanks.

--
eel tech
http://www.hostultra.com/~someguy456/

Jerry Coffin

2002-09-27, 4:29 pm

In article <an2f95$9pvv9$1@ID-160764.news.dfncis.de>,
Anonymous@aol.com says...

[ ... ]

> When I compile this (main.cpp) with g++, "Hello World!" appears in a
> file called a.out, in the same directory as the source, but I don't see
> a binary anywhere.


a.out IS the binary -- if you run it ("./a.out") it should display
"Hello World!", just as you'd expect. You can either rename the file
after creating it, or you can use the -o option (at least with all
the UNIX compilers I've used) to produce the file name you prefer to
start with.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Randy Poe

2002-09-27, 4:29 pm

Anonymous wrote:
>
> I'm learning how to use C++, but I've been limited to Windows. How would
> I go aout to write programs for linux (mandrake 8.2)? I'm trying to
> write simple i/o, nothing with graphics or any of that.
>
> When I compile this (main.cpp) with g++, "Hello World!" appears in a
> file called a.out, in the same directory as the source, but I don't see
> a binary anywhere.


For reasons which (for me anyway) are unknown and lost
in history, "a.out" is the default name of the executable
produced by compilers on Unix systems. If you want a
meaningful name, you have to use a switch, usually -o:
e.g., g++ -o hello main.cpp

In Unix systems, there are common conventions on
file extensions but it isn't magic. "a.out" is
a perfectly good name for an executable. You can
type "a.out" at the command prompt and it will run.
Or rename it to something else if you like.

- Randy
Randy Poe

2002-09-27, 5:29 pm

Anonymous wrote:
>
> I'm learning how to use C++, but I've been limited to Windows. How would
> I go aout to write programs for linux (mandrake 8.2)? I'm trying to
> write simple i/o, nothing with graphics or any of that.
>
> When I compile this (main.cpp) with g++, "Hello World!" appears in a
> file called a.out, in the same directory as the source, but I don't see
> a binary anywhere.


For reasons which (for me anyway) are unknown and lost
in history, "a.out" is the default name of the executable
produced by compilers on Unix systems. If you want a
meaningful name, you have to use a switch, usually -o:
e.g., g++ -o hello main.cpp

In Unix systems, there are common conventions on
file extensions but it isn't magic. "a.out" is
a perfectly good name for an executable. You can
type "a.out" at the command prompt and it will run.
Or rename it to something else if you like.

- Randy
Lew Pitcher

2002-09-30, 12:29 am

Anonymous wrote:
[snip]
> When I compile this (main.cpp) with g++, "Hello World!" appears in a
> file called a.out, in the same directory as the source, but I don't see
> a binary anywhere.


'a.out' _is_ the binary (unless you specifically tell the C++ compiler
to call it something else)

[snip]

--
Lew Pitcher

Master Codewright and JOAT-in-training
Registered (Slackware) Linux User #112576 (http://counter.li.org/)
begin 112576

Lew Pitcher

2002-09-30, 1:29 am

Anonymous wrote:
[snip]
> When I compile this (main.cpp) with g++, "Hello World!" appears in a
> file called a.out, in the same directory as the source, but I don't see
> a binary anywhere.


'a.out' _is_ the binary (unless you specifically tell the C++ compiler
to call it something else)

[snip]

--
Lew Pitcher

Master Codewright and JOAT-in-training
Registered (Slackware) Linux User #112576 (http://counter.li.org/)
begin 112576

Sponsored Links





Free Braindumps | MCSE braindumps software forum

Copyright 2003 - 2008 examnotes.net