C++ code wont execute under Linux.

P

penguinman

I type ./a.out and the shell just sits there. It doesnt hang it just
sits there looking pretty.

I run the program with the ddd option and executed it from
ddd...execution window comes up and nothing shows up.
I used anjuta same thing. No compiler errors no warnings but it wont
execute.
Checked the permisions of the file and its execute..tried with no
execute from desperation,....same shit.
And yeah i got make.

WTF is missing?

As I said, during compile, NO ERRORS and NO WARNINGS. I demoted my
self to a simple hello world program just to keep things simple
 
H

Howard

penguinman said:
I type ./a.out and the shell just sits there. It doesnt hang it just
sits there looking pretty.

I run the program with the ddd option and executed it from
ddd...execution window comes up and nothing shows up.
I used anjuta same thing. No compiler errors no warnings but it wont
execute.
Checked the permisions of the file and its execute..tried with no
execute from desperation,....same shit.
And yeah i got make.

WTF is missing?

As I said, during compile, NO ERRORS and NO WARNINGS. I demoted my
self to a simple hello world program just to keep things simple

So why haven't you posted the code? How are we supposed to know what might
be wrong with nothing to go by? If it's Linux help or compiler help you
need, then ask in a newsgroup dedicated to those topics. We help with C++
problems here, and you've not posted any C++ code to look at.

-Howard
 
M

Mike Wahler

penguinman said:
I type ./a.out and the shell just sits there. It doesnt hang it just
sits there looking pretty.

I run the program with the ddd option and executed it from
ddd...execution window comes up and nothing shows up.
I used anjuta same thing. No compiler errors no warnings but it wont
execute.
Checked the permisions of the file and its execute..tried with no
execute from desperation,....same shit.
And yeah i got make.

WTF is missing?

As I said, during compile, NO ERRORS and NO WARNINGS. I demoted my
self to a simple hello world program just to keep things simple

You have a bug on line 37.

-Mike
 
V

Victor Bazarov

penguinman said:
[...]

WTF is missing?

As I said, during compile, NO ERRORS and NO WARNINGS. I demoted my
self to a simple hello world program just to keep things simple

This is FAQ 5.8

Victor
 
B

Bob Jacobs

penguinman said:
I type ./a.out and the shell just sits there. It doesnt hang it just
sits there looking pretty.

I run the program with the ddd option and executed it from
ddd...execution window comes up and nothing shows up.
I used anjuta same thing. No compiler errors no warnings but it wont
execute.
Checked the permisions of the file and its execute..tried with no
execute from desperation,....same shit.
And yeah i got make.

WTF is missing?

As I said, during compile, NO ERRORS and NO WARNINGS. I demoted my
self to a simple hello world program just to keep things simple

Are you flushing the output stream? Try the following (in the absence of any
posted code on your part):

#include <iostream>
int main()
{
std::cout << "hello, world" << std::flush;
}
 
K

Kevin Goodsell

Bob said:
Are you flushing the output stream? Try the following (in the absence of any
posted code on your part):

#include <iostream>
int main()
{
std::cout << "hello, world" << std::flush;
}

That's not good enough. First, cout will be flushed automatically when
it is destroyed (I think).

Second, flushing alone does not guarantee the text is displayed. Only
*lines* are guaranteed to be displayed. If your output doesn't end with
a newline, bad things can happen. One thing that's likely is that the
system prompt will overwrite your last line of text.

Better change that std::flush to std::endl, or else add a '\n'.

-Kevin
 
P

penguinman

Bob Jacobs said:
Are you flushing the output stream? Try the following (in the absence of any
posted code on your part):

#include <iostream>
int main()
{
std::cout << "hello, world" << std::flush;
}

Yes and its a no go still...:( no errors no warning everything goes
well besides the execution part :(
 
K

Kevin Goodsell

penguinman said:
Yes and its a no go still...:( no errors no warning everything goes
well besides the execution part :(

If that's still the case after replacing std::flush with std::endl, then
you should ask your question on a group that supports your particular
compiler. Once the code is correct, if it still doesn't work, the issue
is with the compiler not the language.

-Kevin
 
P

penguinman

Bob Jacobs said:
Are you flushing the output stream? Try the following (in the absence of any
posted code on your part):

#include <iostream>
int main()
{
std::cout << "hello, world" << std::flush;
}

#include <iostream>
using std::cout;
using std::endl;
using std::cin;
int main ()
{
int x;
cin >>x;
cout<< x<<std::flush;

return 0;

}


Simple code as I said....i run anjuta via shell and when i hit execute i get
in the shell a
Gnome-Message: res is -1 instead of 4
Gnome-Message: gnome_execute_async_with_env_fds: returning -1
/bin/bash: line 1: gnome-terminal: command not found
 
K

Kevin Goodsell

penguinman said:
#include <iostream>
using std::cout;
using std::endl;
using std::cin;
int main ()
{
int x;
cin >>x;
cout<< x<<std::flush;

Your programs output must end with a newline if you expect it to be
displayed. Have you been reading the replies?
return 0;

}

-Kevin
 
A

Alf P. Steinbach

#include <iostream>
using std::cout;
using std::endl;
using std::cin;
int main ()
{
int x;
cin >>x;
cout<< x<<std::flush;

return 0;

}


Simple code as I said....i run anjuta via shell and when i hit execute i get
in the shell a
Gnome-Message: res is -1 instead of 4
Gnome-Message: gnome_execute_async_with_env_fds: returning -1
/bin/bash: line 1: gnome-terminal: command not found

That is not a C++ question, it's an off-topic tool question.

But perhaps you're expecting that the program should display a prompt
or something.

It doesn't because you haven't told it to.
 
N

Noah Roberts

penguinman said:
/bin/bash: line 1: gnome-terminal: command not found


gnome-terminal could not be found. It is not in your path or is
entirely missing from your system. You must install it or find a
suitable replacement (xterm might do but I don't know if the command
args match).

This might be a question better geared toward comp.os.linux.development.apps

NR
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top