Discussion:
C++ std::cout -> Where does it go?
(too old to reply)
silversurfer
2006-11-27 15:31:31 UTC
Permalink
Hello world,
I have written a program, which uses QT as GUI and which runs happily
in OS X and Linux. I can start the program in Ubuntu using
./myApp
and all the output I send with std::cout << "Test" (etc) can be seen
directly in the Shell-Window.

In OS X Terminal, I use
open myApp.app
to start the program. However, the terminal is accessable right away,
because the program is started as a new process (outside the terminal).
Thus, the output from std::cout cannot be seen anywhere.

How can I start a program in OS X such that the std::cout elements can
be seen somewhere or how can I make it visible?

Thanks a lot in advance
Tim
b***@gmail.com
2006-11-27 15:38:26 UTC
Permalink
I think it might go to your "console.log". The usual way to get to this
is to open the Console.app located in /Applications/Utilities. The
physical file is located under /Library/Logs/Console/<uid>/. Someone
correct me if I am wrong or TIAS.

-- Brian Ray (http://kazavoo.com/)
Daniel Höpfl
2006-11-27 20:35:47 UTC
Permalink
Hello!
Post by silversurfer
I have written a program, which uses QT as GUI and which runs happily
in OS X and Linux. I can start the program in Ubuntu using
../myApp
and all the output I send with std::cout << "Test" (etc) can be seen
directly in the Shell-Window.
In OS X Terminal, I use
open myApp.app
to start the program. However, the terminal is accessable right away,
because the program is started as a new process (outside the terminal).
Thus, the output from std::cout cannot be seen anywhere.
How can I start a program in OS X such that the std::cout elements can
be seen somewhere or how can I make it visible?
Go into the bundle: cd myApp.app/Contents/MacOS and start the executable
from there (should be ./myApp).

open sends the given file to the default application which is - for
applications - the Finder. Starting applications with the Finder
connects stdout with /dev/null and everything written to stderr is sent
to console.log.

HTH,
Daniel
silversurfer
2006-11-28 10:08:38 UTC
Permalink
Thanks a lot for the tips, this is how I solved it...
Post by Daniel Höpfl
Hello!
Post by silversurfer
I have written a program, which uses QT as GUI and which runs happily
in OS X and Linux. I can start the program in Ubuntu using
../myApp
and all the output I send with std::cout << "Test" (etc) can be seen
directly in the Shell-Window.
In OS X Terminal, I use
open myApp.app
to start the program. However, the terminal is accessable right away,
because the program is started as a new process (outside the terminal).
Thus, the output from std::cout cannot be seen anywhere.
How can I start a program in OS X such that the std::cout elements can
be seen somewhere or how can I make it visible?
Go into the bundle: cd myApp.app/Contents/MacOS and start the executable
from there (should be ./myApp).
At first, this did not work because some files were leaded from other
sources, and the relative paths did not work from within
myApp.app/Contents/... However, in Qt there is the option not to build
the files as a bundle but directly. This gives more Linux-Style files
which can be started directly by typing ./myApp

Having changed this option in the project file by CONFIG-=app_bundle
and rebuilt the whole thing, I can now start the application by ./myApp
and the output goes where it belongs: The terminal.
Post by Daniel Höpfl
open sends the given file to the default application which is - for
applications - the Finder. Starting applications with the Finder
connects stdout with /dev/null and everything written to stderr is sent
to console.log.
Good to know, thanks!

Greetings
Tim
Post by Daniel Höpfl
HTH,
Daniel
Michael Ash
2006-11-28 15:56:09 UTC
Permalink
Post by silversurfer
At first, this did not work because some files were leaded from other
sources, and the relative paths did not work from within
myApp.app/Contents/... However, in Qt there is the option not to build
the files as a bundle but directly. This gives more Linux-Style files
which can be started directly by typing ./myApp
If you want something that acts like a normal Mac applicaiton then you
should continue to build a bundled .app. (You should also avoid Qt, but
that's a topic for another day.) The problem is not the bundled app, but
rather that Mac applications cannot depend on the working directory to be
set to anything useful when they start. If your code needs the working
directory to be set to, for example, your Contents/Resources directory,
then you should set it yourself. You can do this by using CFBundle to
get/construct the path, then set the working directory appropriately early
on in your code.
--
Michael Ash
Rogue Amoeba Software
David C.
2006-11-28 15:56:11 UTC
Permalink
Post by silversurfer
I have written a program, which uses QT as GUI and which runs happily
in OS X and Linux. I can start the program in Ubuntu using
./myApp
and all the output I send with std::cout << "Test" (etc) can be seen
directly in the Shell-Window.
In OS X Terminal, I use
open myApp.app
to start the program. However, the terminal is accessable right away,
because the program is started as a new process (outside the terminal).
Thus, the output from std::cout cannot be seen anywhere.
How can I start a program in OS X such that the std::cout elements can
be seen somewhere or how can I make it visible?
If this is just for debugging, you can run your app from within the
Xcode environment. It redirects all this output to a window.

-- David

Loading...